Skip to content

Commit 723dbcc

Browse files
committed
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]>
1 parent cb90a31 commit 723dbcc

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
@@ -626,6 +626,23 @@ Make built-in language features like `eval` and `new Function` that generate
626626
code from strings throw an exception instead. This does not affect the Node.js
627627
`node:vm` module.
628628

629+
### `--expose-gc`
630+
631+
<!-- YAML
632+
added: REPLACEME
633+
-->
634+
635+
> Stability: 1 - Experimental. This flag is inherited from V8 and is subject to
636+
> change upstream.
637+
638+
This flag will expose the gc extension from V8.
639+
640+
```js
641+
if (global.gc) {
642+
global.gc();
643+
}
644+
```
645+
629646
### `--dns-result-order=order`
630647

631648
<!-- YAML
@@ -2776,6 +2793,7 @@ V8 options that are allowed are:
27762793
* `--abort-on-uncaught-exception`
27772794
* `--disallow-code-generation-from-strings`
27782795
* `--enable-etw-stack-walking`
2796+
* `--expose-gc`
27792797
* `--huge-max-old-generation-size`
27802798
* `--interpreted-frames-native-stack`
27812799
* `--jitless`
@@ -3098,6 +3116,8 @@ documented here:
30983116

30993117
### `--enable-etw-stack-walking`
31003118

3119+
### `--expose-gc`
3120+
31013121
### `--harmony-shadow-realm`
31023122

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

src/node_options.cc

+1
Original file line numberDiff line numberDiff line change
@@ -473,6 +473,7 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
473473
AddOption("--experimental-report", "", NoOp{}, kAllowedInEnvvar);
474474
AddOption(
475475
"--experimental-wasi-unstable-preview1", "", NoOp{}, kAllowedInEnvvar);
476+
AddOption("--expose-gc", "expose gc extension", V8Option{}, kAllowedInEnvvar);
476477
AddOption("--expose-internals", "", &EnvironmentOptions::expose_internals);
477478
AddOption("--frozen-intrinsics",
478479
"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)