Skip to content

forcing heap snapshot via signal does not allow specifying custom directory #47842

Closed
@mateodelnorte

Description

@mateodelnorte

Version

18

Platform

mac

Subsystem

No response

What steps will reproduce the bug?

  1. start node process with node --heapsnapshot-signal=SIGUSR2 --diagnostic-dir=/opt/crashes test.js
  2. send signal to snapshot with kill -USR2 [pid]
  3. application will attempt to write the heap shapshot to cwd

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueIssues that are suitable for first-time contributors.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions