-
Notifications
You must be signed in to change notification settings - Fork 2k
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
apollo-server
's stop() hangs when running in jest jsdom browser-emulation mode due to lack of timer.unref
#4933
Comments
When I run the code not from jest, everything works fine and the server stops, so I assume it's related to the fact that I run this from Jest + react testing library, and that the code runs from jsdom . (This works perfectly fine:
) |
Update - it seems that the stoppable code can't run from jsdom. As a temp solution, I added a polyfill for setTimeout(...).unref, like so:
It's not a good solution IMO, but it makes server.stop() work and that's good enough for me for now. |
Hi, I appreciate the test file but since it sounds like this issue is very specific to the particular way you run jest with jsdom, is it possible to give a bit more context on how to run it? eg maybe as a git repo I can clone, or something like codesandbox.io? If the issue is unref, then one workaround would be to pass I'm definitely also open to forking |
Let's see if upstream takes hunterloftis/stoppable#33 |
apollo-server
's stop() hangs when running in jest jsdom browser-emulation mode due to lack of timer.unref
(In AS3.1, we inlined the |
I write tests uning Jest + react testing library + jsdom 15. In one of the tests I use ApolloServer - I start it beforeAll and stop it after all.
When I used apollo-server version 2.19.0 everything worked as expected. When upgrading to apollo-server version 2.21.0,
server.stop() hangs forever. I try using stopGracePeriodMillis and that doesn't work as well.
[ apollo-server version 2.21.0 ] The package name and version of Apollo showing the problem.
[ apollo-server version 2.19.0 ] The last version of Apollo where the problem did not occur.
[ server.stop() should work and stop the server ] The expected behavior.
[ instead It's stuck and never reaches the following code ] The actual behavior.
A simple, runnable reproduction!
My guess is that this change broke the stop functionality, maybe because the code runs from jsdom browser + jest, and stoppable might have issues with it.
Update:
I think my guess is correct, I found this in the jsdom browser console:
Thank you!
The text was updated successfully, but these errors were encountered: