Skip to content

Commit 64b140d

Browse files
juanarbolmarco-ippolito
authored andcommittedJan 24, 2025
cli: add --heap-prof flag available to NODE_OPTIONS
Fixes: #54257 Signed-off-by: Juan José Arboleda <soyjuanarbol@gmail.com> PR-URL: #54259 Reviewed-By: Zeyu "Alex" Yang <himself65@outlook.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
1 parent 0977bb6 commit 64b140d

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed
 

Diff for: ‎doc/api/cli.md

+4
Original file line numberDiff line numberDiff line change
@@ -2777,6 +2777,10 @@ one is included in the list below.
27772777
* `--force-fips`
27782778
* `--force-node-api-uncaught-exceptions-policy`
27792779
* `--frozen-intrinsics`
2780+
* `--heap-prof-dir`
2781+
* `--heap-prof-interval`
2782+
* `--heap-prof-name`
2783+
* `--heap-prof`
27802784
* `--heapsnapshot-near-heap-limit`
27812785
* `--heapsnapshot-signal`
27822786
* `--http-parser`

Diff for: ‎src/node_options.cc

+8-4
Original file line numberDiff line numberDiff line change
@@ -620,19 +620,23 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
620620
"Start the V8 heap profiler on start up, and write the heap profile "
621621
"to disk before exit. If --heap-prof-dir is not specified, write "
622622
"the profile to the current working directory.",
623-
&EnvironmentOptions::heap_prof);
623+
&EnvironmentOptions::heap_prof,
624+
kAllowedInEnvvar);
624625
AddOption("--heap-prof-name",
625626
"specified file name of the V8 heap profile generated with "
626627
"--heap-prof",
627-
&EnvironmentOptions::heap_prof_name);
628+
&EnvironmentOptions::heap_prof_name,
629+
kAllowedInEnvvar);
628630
AddOption("--heap-prof-dir",
629631
"Directory where the V8 heap profiles generated by --heap-prof "
630632
"will be placed.",
631-
&EnvironmentOptions::heap_prof_dir);
633+
&EnvironmentOptions::heap_prof_dir,
634+
kAllowedInEnvvar);
632635
AddOption("--heap-prof-interval",
633636
"specified sampling interval in bytes for the V8 heap "
634637
"profile generated with --heap-prof. (default: 512 * 1024)",
635-
&EnvironmentOptions::heap_prof_interval);
638+
&EnvironmentOptions::heap_prof_interval,
639+
kAllowedInEnvvar);
636640
#endif // HAVE_INSPECTOR
637641
AddOption("--max-http-header-size",
638642
"set the maximum size of HTTP headers (default: 16384 (16KB))",

Diff for: ‎test/parallel/test-process-env-allowed-flags-are-documented.js

+12
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@ const difference = (setA, setB) => {
8686
return new Set([...setA].filter((x) => !setB.has(x)));
8787
};
8888

89+
// Remove heap prof options if the inspector is not enabled.
90+
// NOTE: this is for ubuntuXXXX_sharedlibs_withoutssl_x64, no SSL, no inspector
91+
// Refs: https://github.com/nodejs/node/pull/54259#issuecomment-2308256647
92+
if (!process.features.inspector) {
93+
[
94+
'--heap-prof-dir',
95+
'--heap-prof-interval',
96+
'--heap-prof-name',
97+
'--heap-prof',
98+
].forEach((opt) => documented.delete(opt));
99+
}
100+
89101
const overdocumented = difference(documented,
90102
process.allowedNodeEnvironmentFlags);
91103
assert.strictEqual(overdocumented.size, 0,

0 commit comments

Comments
 (0)