node-clinic icon indicating copy to clipboard operation
node-clinic copied to clipboard

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

Open fr-nevin opened this issue 6 years ago • 18 comments

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

  • Clinic.js version: "4.0.3",

  • Node.js version: 10.15.3, npm - 6.4.1

  • Browser name and version: Chrome Version 73.0.3683.103

  • Operating system and version: Your OS is OS X 10.14.1 [Mac OS Mojave]

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.)

fr-nevin avatar May 14 '19 07:05 fr-nevin

Can you include a script that is triggering this behavior?

mcollina avatar May 14 '19 08:05 mcollina

@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 avatar May 14 '19 08:05 fr-nevin

@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 avatar May 14 '19 08:05 fr-nevin

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

fr-nevin avatar May 14 '19 08:05 fr-nevin

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

goto-bus-stop avatar May 14 '19 12:05 goto-bus-stop

@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 avatar May 15 '19 00:05 fr-nevin

@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.

fr-nevin avatar May 15 '19 03:05 fr-nevin

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

DylanC avatar Feb 17 '20 15:02 DylanC

This is working on Mac for me.

  • Clinic.js version: "5.0.0",
  • Node.js version: 12.16, npm - 6.13.4
  • Browser name and version: Chrome Version 80.0.3987.122
  • Operating system and version: Your OS is OS X 10.15.3

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 avatar Mar 04 '20 11:03 DylanC

Dup of #152

DylanC avatar Mar 04 '20 11:03 DylanC

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!

nath-abhishek avatar Oct 01 '20 01:10 nath-abhishek

Hi, I am having this issue on Windows

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

MiloVahos avatar Mar 19 '21 14:03 MiloVahos

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

ajay-desai avatar Sep 22 '21 18:09 ajay-desai

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?

DmytroSokhach avatar Oct 20 '21 13:10 DmytroSokhach

@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.

DylanC avatar Oct 23 '21 19:10 DylanC

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/ [email protected])

process.on('SIGINT', function() {
// do your handling 
// exit the process
    process.exit();
});

bijeshp avatar Nov 10 '21 00:11 bijeshp

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

Jakeii avatar Mar 13 '22 15:03 Jakeii

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

  • Clinic.js: "^13.0.0",
  • Node.js : ">=10.19.0",
  • "npm": "~3.10.0"

Jood80 avatar May 14 '24 11:05 Jood80