0x icon indicating copy to clipboard operation
0x copied to clipboard

Allow `Ctrl+C` to stop the target process and generate flamegraph from collected data

Open edi9999 opened this issue 6 months ago • 1 comments

Hello 👋

Thanks for the great project — it has already been very helpful!

In my case, I’m profiling a long-running script (which can hang or take several hours to complete), and I would like to profile it without modifying the code at all — a "zero-modification" profiling workflow.

I'm running:

npx 0x ./node_modules/.bin/mocha es6/test.js

The script starts fine, and I see:

🔥  Profiling

  New test
🔥  Waiting for subprocess to exit...
🔥  Force closing subprocess...
🔥  Closing subprocess is taking a long time, it might have hung. Press Ctrl+C again to force close

After a few minutes, I hit Ctrl+C, hoping this would:

  • stop the mocha subprocess,
  • and generate the flamegraph from whatever profiling data had been recorded so far.

However, this doesn’t seem to work: either the process hangs, or the flamegraph isn’t produced.

It would be great if 0x could:

  • respond to Ctrl+C by terminating the subprocess,
  • and still generate a flamegraph from the collected data.

This would really help in cases where the script doesn’t exit cleanly or is stuck at 100% CPU.

Thanks again for your work!

edi9999 avatar May 30 '25 11:05 edi9999

It worked in this way prior to latest node.js releases. I guess something has changed. A PR would be amazing.

mcollina avatar May 31 '25 23:05 mcollina

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.

github-actions[bot] avatar Jul 01 '25 02:07 github-actions[bot]

This issue was closed because it has been stalled for 5 days with no activity.

github-actions[bot] avatar Jul 07 '25 02:07 github-actions[bot]