Skip to content

Commit 7ed058c

Browse files
juanarbolruyadorno
authored andcommitted
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 e14dba3 commit 7ed058c

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

doc/api/cli.md

+4
Original file line numberDiff line numberDiff line change
@@ -3092,6 +3092,10 @@ one is included in the list below.
30923092
* `--force-fips`
30933093
* `--force-node-api-uncaught-exceptions-policy`
30943094
* `--frozen-intrinsics`
3095+
* `--heap-prof-dir`
3096+
* `--heap-prof-interval`
3097+
* `--heap-prof-name`
3098+
* `--heap-prof`
30953099
* `--heapsnapshot-near-heap-limit`
30963100
* `--heapsnapshot-signal`
30973101
* `--http-parser`

src/node_options.cc

+8-4
Original file line numberDiff line numberDiff line change
@@ -629,19 +629,23 @@ EnvironmentOptionsParser::EnvironmentOptionsParser() {
629629
"Start the V8 heap profiler on start up, and write the heap profile "
630630
"to disk before exit. If --heap-prof-dir is not specified, write "
631631
"the profile to the current working directory.",
632-
&EnvironmentOptions::heap_prof);
632+
&EnvironmentOptions::heap_prof,
633+
kAllowedInEnvvar);
633634
AddOption("--heap-prof-name",
634635
"specified file name of the V8 heap profile generated with "
635636
"--heap-prof",
636-
&EnvironmentOptions::heap_prof_name);
637+
&EnvironmentOptions::heap_prof_name,
638+
kAllowedInEnvvar);
637639
AddOption("--heap-prof-dir",
638640
"Directory where the V8 heap profiles generated by --heap-prof "
639641
"will be placed.",
640-
&EnvironmentOptions::heap_prof_dir);
642+
&EnvironmentOptions::heap_prof_dir,
643+
kAllowedInEnvvar);
641644
AddOption("--heap-prof-interval",
642645
"specified sampling interval in bytes for the V8 heap "
643646
"profile generated with --heap-prof. (default: 512 * 1024)",
644-
&EnvironmentOptions::heap_prof_interval);
647+
&EnvironmentOptions::heap_prof_interval,
648+
kAllowedInEnvvar);
645649
#endif // HAVE_INSPECTOR
646650
AddOption("--max-http-header-size",
647651
"set the maximum size of HTTP headers (default: 16384 (16KB))",

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)