From 358a1ddc84f4c84b3e53aa5593591eed2ebd7ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9=20Arboleda?= Date: Mon, 20 May 2024 23:02:09 -0500 Subject: [PATCH] cli: add `--expose-gc` flag available to `NODE_OPTIONS` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- doc/api/cli.md | 20 ++++++++++++++++++++ src/node_options.cc | 1 + test/parallel/test-cli-node-options.js | 1 + 3 files changed, 22 insertions(+) diff --git a/doc/api/cli.md b/doc/api/cli.md index f686ffade8f421..4344353980c671 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -626,6 +626,23 @@ Make built-in language features like `eval` and `new Function` that generate code from strings throw an exception instead. This does not affect the Node.js `node:vm` module. +### `--expose-gc` + + + +> Stability: 1 - Experimental. This flag is inherited from V8 and is subject to +> change upstream. + +This flag will expose the gc extension from V8. + +```js +if (globalThis.gc) { + globalThis.gc(); +} +``` + ### `--dns-result-order=order`