Skip to content

Commit 638b510

Browse files
juanarbolRafaelGSS
authored andcommitted
cli: add --expose-gc flag available to NODE_OPTIONS
This commits allows users to send `--expose-gc` via `NODE_OPTIONS` environment variable. Using `node --expose-gc` is possible but via `NODE_OPTIONS` won't work. ```sh NODE_OPTIONS='--expose-gc' node node: --expose-gc is not allowed in NODE_OPTIONS ``` Signed-off-by: Juan José Arboleda <[email protected]> PR-URL: #53078 Reviewed-By: Tierney Cyren <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]>
1 parent 4a17dda commit 638b510

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

doc/api/cli.md

+20
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,23 @@ Make built-in language features like `eval` and `new Function` that generate
673673
code from strings throw an exception instead. This does not affect the Node.js
674674
`node:vm` module.
675675

676+
### `--expose-gc`
677+
678+
<!-- YAML
679+
added: REPLACEME
680+
-->
681+
682+
> Stability: 1 - Experimental. This flag is inherited from V8 and is subject to
683+
> change upstream.
684+
685+
This flag will expose the gc extension from V8.
686+
687+
```js
688+
if (globalThis.gc) {
689+
globalThis.gc();
690+
}
691+
```
692+
676693
### `--dns-result-order=order`
677694

678695
<!-- YAML
@@ -2913,6 +2930,7 @@ V8 options that are allowed are:
29132930
* `--abort-on-uncaught-exception`
29142931
* `--disallow-code-generation-from-strings`
29152932
* `--enable-etw-stack-walking`
2933+
* `--expose-gc`
29162934
* `--huge-max-old-generation-size`
29172935
* `--interpreted-frames-native-stack`
29182936
* `--jitless`
@@ -3242,6 +3260,8 @@ documented here:
32423260

32433261
### `--enable-etw-stack-walking`
32443262

3263+
### `--expose-gc`
3264+
32453265
### `--harmony-shadow-realm`
32463266

32473267
### `--huge-max-old-generation-size`

src/node_options.cc

+1
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,7 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
489489
AddOption("--experimental-report", "", NoOp{}, kAllowedInEnvvar);
490490
AddOption(
491491
"--experimental-wasi-unstable-preview1", "", NoOp{}, kAllowedInEnvvar);
492+
AddOption("--expose-gc", "expose gc extension", V8Option{}, kAllowedInEnvvar);
492493
AddOption("--expose-internals", "", &EnvironmentOptions::expose_internals);
493494
AddOption("--frozen-intrinsics",
494495
"experimental frozen intrinsics support",

test/parallel/test-cli-node-options.js

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ if (common.hasCrypto) {
6969
// V8 options
7070
expect('--abort_on-uncaught_exception', 'B\n');
7171
expect('--disallow-code-generation-from-strings', 'B\n');
72+
expect('--expose-gc', 'B\n');
7273
expect('--huge-max-old-generation-size', 'B\n');
7374
expect('--jitless', 'B\n');
7475
expect('--max-old-space-size=0', 'B\n');

0 commit comments

Comments
 (0)