clinicjs / node-clinic

Clinic.js diagnoses your Node.js performance issues
https://clinicjs.org
MIT License
5.67k stars 125 forks source link

Unexpected behaviour of "--dest" argument in heapprofiler mode #450

Closed alexandervain closed 1 year ago

alexandervain commented 1 year ago

Expected Behavior

--dest would accept a path to a folder, that is, the following execution would store the result under the /my-custom-folder folder:

clinic heapprofiler --dest /my-custom-folder -- node .

This is also the behaviour described in the docs: --dest Destination for the collect data (default .).

Current Behavior

The --dest argument is treated as a file path in heapprofiler mode. The above command results in such error:

[Error: EISDIR: illegal operation on a directory, open '/my-custom-folder'] {
  errno: -21,
  code: 'EISDIR',
  syscall: 'open',
  path: '/my-custom-folder'
}
[    ] Analysing dataError: Child process exited with code 1.
    at ChildProcess.<anonymous> (/usr/local/lib/node_modules/clinic/node_modules/@clinic/heap-profiler/src/index.js:43:12)
    at Object.onceWrapper (node:events:646:26)
    at ChildProcess.emit (node:events:526:28)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)

Steps to Reproduce (for bugs)

Pass path to a folder in the --dest argument:

clinic heapprofiler --dest /my-custom-folder -- node .

Environment