Repository navigation
forcing heap snapshot via signal does not allow specifying custom directory #47842
Copy link
Copy link
Closed
Labels
good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.
Description
Activity
- addedgood first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.
on May 4, 2023 Pull request welcome. The relevant code is here:
node/lib/internal/process/pre_execution.js
Lines 366 to 387 in 76ae7be
function initializeHeapSnapshotSignalHandlers() { const signal = getOptionValue('--heapsnapshot-signal'); if (!signal) return; require('internal/validators').validateSignalName(signal); const { writeHeapSnapshot } = require('v8'); function doWriteHeapSnapshot() { writeHeapSnapshot(); } process.on(signal, doWriteHeapSnapshot); // The code above would add the listener back during deserialization, // if applicable. if (isBuildingSnapshot()) { addSerializeCallback(() => { process.removeListener(signal, doWriteHeapSnapshot); }); } } I am on it.
I was actually in the process of creating a PR. Can I go ahead with it? I saw that it was labeled as a good first issue and I wanted to make a contribution.
Sorry. Next time, you can comment on the issue and take the work. So that, we can avoid the duplicate work.
Reacted by Alex Gorunescu and hub_Prateek- added a commit that references this issue
on Sep 5, 2023 It looks like this issue hasn't been responded to in a while, so I created the PR: #49496
Completed in #47854
- added a commit that references this issue
on Sep 28, 2023 - added a commit that references this issue
on Jun 19, 2026
Metadata
Metadata
Assignees
Labels
good first issueIssues that are suitable for first-time contributors.Issues that are suitable for first-time contributors.
Version
18
Platform
mac
Subsystem
No response
What steps will reproduce the bug?
node --heapsnapshot-signal=SIGUSR2 --diagnostic-dir=/opt/crashes test.jskill -USR2 [pid]Why is this important? --diagnostics-dir is currently being used to write files for heap profiling, but not ad-hoc heap dumps. When running in a production environment, the application cwd is often read only. Application developers must be able to specify where heap dumps will be saved.
Note, no parameters are being passed into this function execution: https://github.com/nodejs/node/blob/c24a61b3f6815b9d12b491ac869335feff86a24b/lib/internal/process/pre_execution.js#LL376C17-L376C17. A path should be passed to this function, such that the full filename can be constructed.
How often does it reproduce? Is there a required condition?
No response
What is the expected behavior? Why is that the expected behavior?
Note, no parameters are being passed into this function execution: https://github.com/nodejs/node/blob/c24a61b3f6815b9d12b491ac869335feff86a24b/lib/internal/process/pre_execution.js#LL376C17-L376C17. A path should be passed to this function, such that the full filename can be constructed.
What do you see instead?
writeHeapSnapshot(); attempts to write to the cwd. The code path for writing to a provided path is never utilized.
Additional information
No response