-
-
Notifications
You must be signed in to change notification settings - Fork 16
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
feat: add --expose-gc
flag
#4
Conversation
Can you add it to the docs? |
I was trying out a few different ways to achieve this. Since we are using run from node:test here and not spawning a new process, we have two options: 1. Enable gc dynamically (without passing flags to node)import { setFlagsFromString } from 'node:v8';
import { runInNewContext } from 'node:vm';
if (args.values['expose-gc'] && typeof global.gc !== 'function') {
setFlagsFromString('--expose-gc');
global.gc = runInNewContext('gc');
} I tried this, but was unable to use gc inside my tests 2. Spawn a node child process where we pass the
|
I think you can set it to process.env.NODE_OPTIONS before calling |
No that will not work, since it isn't a node option it's a v8 flag. $ node --v8-options
--expose-gc (expose gc extension)
type: bool default: false And passing it as NODE_OPTIONS gives this error
|
I recommend you to open an issue on nodejs to add the possibility to pass nodeOptions to Until that happens, using execa is ok. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
I've made a mistake and landed this while tests are failing on Node v21. Could you send a follow-up pr to fix? |
Yes sure, let me check why they are failing on v21 |
Hey @mcollina you might want to take a look at this, something very weird is happening. All tests are failing on v21.5, but passing on v21.4. When we are running
Do you have any idea what might be the issue? |
Here is the fix: #5 |
Awesome! All tests passing now! |
Addresses #3