-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
Node@15's crypto.randomFillSync() causing "RANDOMBYTESREQUEST potentially keeping Jest from exiting" errors #11275
Comments
Yep, based on what I'm seeing here, jest's async_hook will retain a strong reference to any async resource until it is destroyed. However, there are some async resources that end up being marked weak -- that is, we allow the gc to clean them up once there are no longer any strong references. What jest should be doing here instead is using a Weak reference to the That said, there are cases where the process will exit before performing a final gc, in which case weak objects can still be in memory. |
@broofa I assume the test does exit normally as expected and this is just Jest pointing to something that's not actually an issue in practice? I think we can just exclude those resources from the tracking, like we already do with other resources: If yes, PR welcome very much welcome! 🙂 If no, we'll need to dig into this. @jasnell's observation is very interesting. Should we use e.g. https://www.npmjs.com/package/weak-napi and clear based on that in addition to the explicit resource destruction? |
I'm facing this same issue. In local warning is shown but tests exit successfully, but other work colleagues (maybe because they use Node.js v14 and me v15?) and CI environment (with Node.js v14) |
It's a bit more complicated than that. These particular resources might be async or sync. In the async case, your checks here would still be valuable but can still be problematic in the current implementation. Jest really should be using weak references to track these rather than the current strong references |
@SimenB : The Repl will run to completion if you omit the @piranna has commented on how it's impacted him. I'll invite @guiaramos to do the same. And it looks like at least four other people chimed in on that stackoverflow question so... it's pretty clearly showing up on peoples' radar. |
For reference, Stackoverflow question is https://stackoverflow.com/questions/65653226/jest-and-randombytesrequest-open-handles. |
The flag is only meant to attempt to find stuff that keeps the process going after tests have completed. In this case (reproduction provided) I cannot see that the tests do not complete, and thus it seems to be a warning due to some new async resource type we haven't added to our check rather than a real issue. However, from how I understand @jasnell's comments over in uuidjs/uuid#566, one issue might just be that we do not allow GC to run before collecting. We can definitely manually trigger GC before collecting, and doing so seems to remove the warning. However (at least my approach) also seems to collect a EDIT: Just waiting a tick @piranna I can't see the warning at all for node 14, so I don't think that necessarily related? Would you be able to put together a minimal reproduction? @jasnell I can open up a PR attempting to use |
Issue #11277 doesn't fix this, warning still is shown and when adding the flag |
That's expected, #11278 is the fix for this issue
|
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🐛 Bug Report
Forwarding this from the conversation taking place on uuidjs/uuid#566
TL;DR: Jest's
--detectOpenHandles
logic is getting triggered by recent changes tocrypto.randomFillSync()
. This is causing issues for some Jest users (e.g. https://stackoverflow.com/questions/65653226/jest-and-randombytesrequest-open-handles)Expected Behavior
Calling this (nominally synchronous) method should not trigger this warning. From @jasnell's comment it sounds like this may be a side-effect of how Jest is tracking open handles?
To Reproduce
See Repl supplied below but, briefly ...
crypto.randomFillSync()
jest --detectOpenHandles
... and you'll get an error like this:
Expected Behavior
Link to repl or repo (highly encouraged)
https://replit.com/@broofa/Jest-issue-with-cryptorandomFillSync
(Note that this Repl installs node@15 and runs Jest with that, contrary to the "node 12.x.x." it says at startup.
envinfo
The text was updated successfully, but these errors were encountered: