-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
VM's context when evaluating ESM script not garbage-collected (works with CJS) #50964
Comments
If you take heap snapshots before and after you set the The leak detector is not implemented in a reliable way:
I see that the leak detector seems to come from an old implementation in Jest, I ran into a similar false positive in their previous implementation too, the workaround they did was generating a heap snapshot to "force" a GC: #48510 (comment) (I think this is still somewhat unreliable though, as both 1 and 2 are still true with that approach, it just lowers the chances of false positives but does not eliminate it, though in Node.js core we've still encountered false positives with a similar approach). |
@joyeecheung thank you for the thorough explanation! Much appreciated. |
@joyeecheung one more question if I may, why does the leak-detector work "reliably" for CJS scripts? |
It may just happen to “work” with the given graph (e.g. somehow this leads to enough pressure at the right time for the GC to run in a particular way to get the callback invoked) but it could very well stop working when the implementation of vm.Script or V8’s GC change in a subtle way, which is common for GC-related issues |
Version
latest of 18, 20, 21
Platform
GitHub Actions on ubuntu-latest (and any other platform)
Subsystem
No response
What steps will reproduce the bug?
See https://github.com/enisdenjo/node-leak for repro. Also its failing CI for running repro.
How often does it reproduce? Is there a required condition?
Always.
What is the expected behavior? Why is that the expected behavior?
VM's context gets garbage-collected when evaluating both CJS and ESM scripts.
What do you see instead?
VM's context doesn't get garbage-collected when evaluating ESM script. While with CJS it does.
Additional information
No response
The text was updated successfully, but these errors were encountered: