-
Notifications
You must be signed in to change notification settings - Fork 31.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test_runner: Promise resolution is still pending but the event loop has already resolved #49952
Comments
A couple of notes:
It's not the most intuitive, but I'd say it's at least working as expected. |
Yep
…On Fri, Sep 29, 2023 at 6:56 AM Colin Ihrig ***@***.***> wrote:
A couple of notes:
- Promises alone will not keep the event loop alive, which is why this
is failing. This is true for all Node programs, and Node's test runner
treats every file as a generic Node application. (See #22088
<#22088> and probably many other
issues)
- This is not specific to Node 20. It fails the same way on Node 18.
- I ran your code using Deno's test runner, and it fails there as well.
It's not the most intuitive, but I'd say it's at least working as expected.
—
Reply to this email directly, view it on GitHub
<#49952 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/A7QBBDBVBPQUZSOZSKLBAMTX43HPXANCNFSM6AAAAAA5MPJVWM>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Closing per Colin's comment. |
So how do I keep the event loop alive in my tests @cjihrig ? |
@albertodiazdorado i would imagine by personally i ran into this error because i was doing |
Version
v20.6.1
Platform
Microsoft Windows NT 10.0.19045.0 x64
Subsystem
node:test
What steps will reproduce the bug?
Content of
index.mjs
fileThen run it

node index.mjs
(also work with node --test)If you switch
keepEventLoopAlive
to true my package will not unref the internal timer and the event loop will remain active (and the test suite will be ok).How often does it reproduce? Is there a required condition?
Always reproduce
What is the expected behavior? Why is that the expected behavior?
Should execute with no error for me (the event loop should remain alive).
What do you see instead?
If one test use once (which doesn't keep the loop alive), it return the error
Promise resolution is still pending but the event loop has already resolved
and propagate to all other tests (They all fail with the same error).Additional information
I've encountered this problem on several projects over the past few weeks. One at work on a Fastify test suite where I had to declare a timer to keep the loop alive at the top:
I can't share this code as that not open source (looking to build a reproduction).
It test an API that use a class where
once
is used. I guess Fastify.inject doesn't keep the event loop alive too.The text was updated successfully, but these errors were encountered: