From b26a260ce595a464b933187c72e9ed06880f75f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Jos=C3=A9?= Date: Tue, 4 Jun 2024 12:07:29 -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 PR-URL: https://github.com/nodejs/node/pull/53078 Reviewed-By: Tierney Cyren Reviewed-By: James M Snell Reviewed-By: Joyee Cheung Reviewed-By: Chengzhong Wu --- 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 030e454b66e20e..af9ddd41f04436 100644 --- a/doc/api/cli.md +++ b/doc/api/cli.md @@ -673,6 +673,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`