clinicjs / node-clinic

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

'Ctrl + C' not working for Mac, but works for Linux. #164

Open fr-nevin opened 5 years ago

fr-nevin commented 5 years ago

Expected Behavior

Bug: 'Ctrl+C' stops the doctor, and doesn't even reach to the analyzing part.

Current Behavior

I am trying to run clinic against a script, which needs to be run on background calling a polling function to check if there was an event triggered from the front end. Once the event has been sent from the front end, this polling function takes care of the event. Once it's done. I stop by using Ctrl + C, where the Analyzing bar doesn't appear.

Environment

Additional Info

The same command am using:

clinic doctor --on-port 'autocannon http://localhost:$PORT' -- node tasks/cathy.js works for 2 of my friends Linux PC, but not on my MAC. (Going to confirm with another MAC friend soon. Will update it here.)

mcollina commented 5 years ago

Can you include a script that is triggering this behavior?

fr-nevin commented 5 years ago

@mcollina Hmm, it's a big script at the moment. I might need to make something small and run it. Let me give it a try and see if I can reproduce it.

fr-nevin commented 5 years ago

@mcollina I just put a simple code like this -

const testFunction = () => {
      console.log('testFunction running.....')
}

setInterval(() => {
  testFunction();
}, 1000);

Then press Ctrl+C, it stops at ..

^C[ ] Received Ctrl+C, closing process...

Doesn't work on MAC.

fr-nevin commented 5 years ago

@mcollina But if there's a javascript file, which doesn't require stopping.. it would run it's course and shows the html metrics. 👍

goto-bus-stop commented 5 years ago

Does it only happen with the --on-port flag or also if you omit it?

fr-nevin commented 5 years ago

@goto-bus-stop

clinic doctor 'autocannon http://localhost:$PORT' -- node tools/testFunction.js - Ctrl + C not working.
clinic doctor '--autocannon http://localhost:$PORT' -- node tools/testFunction.js - Ctrl + C not working.
clinic doctor --autocannon -- node tools/testFunction.js - Ctrl + C not working.
clinic doctor --wrk -- node tools/testFunction.js - Ctrl + C not working.

All end up with the result:

^C[ ] Received Ctrl+C, closing process...

And ends the process.

I think problem lies with the handling of the Ctrl+C on MAC. Because, as I said earlier, without Ctrl + C, if it was a small script without a continuous polling, it would show up with the results.

fr-nevin commented 5 years ago

@mcollina @goto-bus-stop Checked against 4 OS's in total (2 MAC and 2 Linux. ) Worked on both the linux, but not the MAC.

DylanC commented 4 years ago

@fr-nevin - Does this issue happen with v5 of Clinic? npm install -g clinic@5

DylanC commented 4 years ago

This is working on Mac for me.

dylanc@dc_mbp Clinic % clinic doctor --on-port 'autocannon http://localhost:$PORT' -- node node-clinic-doctor-examples/slow-io Running 10s test @ http://localhost:3000/ 10 connections

Caught SIGINT, shutting down. [ ] Received Ctrl+C, closing process...Caught SIGINT, shutting down.

Let us know if you have any issues with current versions of Clinic.

DylanC commented 4 years ago

Dup of #152

nath-abhishek commented 4 years ago

Hi, I am still having this issue on Mac.

Clinic.js version: "6.0.3", Node.js version: 12.16.1, npm - 6.13.4 Browser name and version: NA Operating system and version: OS X 10.15.6

Thanks for awesome tool!

MiloVahos commented 3 years ago

Hi, I am having this issue on Windows

Clinic.js version: "7.0.1", Node.js version: 14.15.3, npm - 6.14.9

ajay-desai commented 3 years ago

I'm also having this issue. Mac OS X 11.5.2 Big Sur Node v14.15.1 Clinic v9.0.0

Any work arounds

DmytroSokhach commented 3 years ago

I have the same issue, but if after Ctrl+C (which loops indefinitely I press Enter). The results is:

^C[    ] Received Ctrl+C, closing process...
[   =] Received Ctrl+C, closing process...
events.js:377
      throw er; // Unhandled 'error' event
      ^

Error: read EIO
    at TTY.onStreamRead (internal/stream_base_commons.js:209:20)
Emitted 'error' event on ReadStream instance at:
    at emitErrorNT (internal/streams/destroy.js:106:8)
    at emitErrorCloseNT (internal/streams/destroy.js:74:3)
    at processTicksAndRejections (internal/process/task_queues.js:82:21) {
  errno: -5,
  code: 'EIO',
  syscall: 'read'
}

My setup is: MacOS Big Sur 11.6 Node: v14.17.6 clinic@^9.0.0

@DylanC if there is some workaround for this, could you please share here?

DylanC commented 3 years ago

@DmytroSokhach - I'm not very involved in this project at the moment and I don't currently have access to a Mac. Reopened the issue for now.

bijeshp commented 2 years ago

Look for the SIGINT( catches ctrl+c event) event handlers in your code or the dependencies.

if you have one, exit the process in the handling. This worked for me(OsX Catalina/ clinic@9.0.0)

process.on('SIGINT', function() {
// do your handling 
// exit the process
    process.exit();
});
Jakeii commented 2 years ago

I'm having this issue only for flame. doctor and bubbleprof work just fine

Jood80 commented 5 months ago

Same Issue on generating the reports upon clicking on "ctrl + c" on Linux: