Skip to content

Commit 52da293

Browse files
juanarboladuh95
authored andcommitted
cli: add --heap-prof flag available to NODE_OPTIONS
Fixes: #54257 Signed-off-by: Juan José Arboleda <[email protected]> PR-URL: #54259 Reviewed-By: Zeyu "Alex" Yang <[email protected]> Reviewed-By: Franziska Hinkelmann <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]>
1 parent 0da1632 commit 52da293

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

‎doc/api/cli.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3075,6 +3075,10 @@ one is included in the list below.
30753075
*`--force-fips`
30763076
*`--force-node-api-uncaught-exceptions-policy`
30773077
*`--frozen-intrinsics`
3078+
*`--heap-prof-dir`
3079+
*`--heap-prof-interval`
3080+
*`--heap-prof-name`
3081+
*`--heap-prof`
30783082
*`--heapsnapshot-near-heap-limit`
30793083
*`--heapsnapshot-signal`
30803084
*`--http-parser`

‎src/node_options.cc‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -617,19 +617,23 @@ EnvironmentOptionsParser::EnvironmentOptionsParser(){
617617
"Start the V8 heap profiler on start up, and write the heap profile "
618618
"to disk before exit. If --heap-prof-dir is not specified, write "
619619
"the profile to the current working directory.",
620-
&EnvironmentOptions::heap_prof);
620+
&EnvironmentOptions::heap_prof,
621+
kAllowedInEnvvar);
621622
AddOption("--heap-prof-name",
622623
"specified file name of the V8 heap profile generated with "
623624
"--heap-prof",
624-
&EnvironmentOptions::heap_prof_name);
625+
&EnvironmentOptions::heap_prof_name,
626+
kAllowedInEnvvar);
625627
AddOption("--heap-prof-dir",
626628
"Directory where the V8 heap profiles generated by --heap-prof "
627629
"will be placed.",
628-
&EnvironmentOptions::heap_prof_dir);
630+
&EnvironmentOptions::heap_prof_dir,
631+
kAllowedInEnvvar);
629632
AddOption("--heap-prof-interval",
630633
"specified sampling interval in bytes for the V8 heap "
631634
"profile generated with --heap-prof. (default: 512 * 1024)",
632-
&EnvironmentOptions::heap_prof_interval);
635+
&EnvironmentOptions::heap_prof_interval,
636+
kAllowedInEnvvar);
633637
#endif// HAVE_INSPECTOR
634638
AddOption("--max-http-header-size",
635639
"set the maximum size of HTTP headers (default: 16384 (16KB))",

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@ const difference = (setA, setB) =>{
8686
returnnewSet([...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
constoverdocumented=difference(documented,
90102
process.allowedNodeEnvironmentFlags);
91103
assert.strictEqual(overdocumented.size,0,

0 commit comments

Comments
(0)