Skip to content

Add CLI option for specifying heapsnapshot prefix filename #40363

Description

@paulrutter

The CLI option --heapsnapshot-near-heap-limit was introduced to Node.js 14.18.0 in #33010. Although this works as expected, i have a usecase where i would like to predefine how the heapsnapshot file will be named (when it goes out of memory).
The usecase is about a main node process forking several child processes. When one of those goes out of memory, i would like to know which one it is (based on the given prefix filename).

See #33010 (comment).

Desired behavior
Have a new CLI option called --heapsnapshot-filename-prefix which is used to prepend the default filename (Heap.YYYYMMDD.HHmmSS.${pid}.${threadid}.${count}.heapsnapshot).

For example:
node --heapsnapshot-filename-prefix=FooHeapsnapshot --heapsnapshot-near-heap-limit=1 would lead to FooHeapsnapshot.YYYYMMDD.HHmmSS.${pid}.${threadid}.${count}.heapsnapshot when an out of memory occurs.

Current alternative
Current workaround would be to keep track of a forked process process id, and use that to rename a possible heapsnapshot when the process has exited.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    cliIssues and PRs related to the Node.js command-line interface.feature requestIssues requesting new Node.js features.staleIssues and PRs marked stale due to inactivity and scheduled for automatic closure.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions