cli icon indicating copy to clipboard operation
cli copied to clipboard

[BUG] SIGINT called twice

Open alesmenzel opened this issue 3 years ago • 2 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

This issue exists in the latest npm version

  • [X] I am using the latest npm

Current Behavior

SIGINT is called twice, immediately terminating the process, causing any cleanup code that runs on SIGINT unable to run without hacking around and handling npm double fire or running the process outside of npm run

Expected Behavior

SIGINT is called just once

Steps To Reproduce

// some-script
#!/usr/bin/env node

// just to keep the process running
setInterval(() => {}, 10000)

process.on('SIGINT', () => {
  console.log('SIGINT')
})
// package.json
"scripts": {
  "doSomething": "./some-script"
}

and run it

npm run doSomething

and the output

> <project>@<version> doSomething
> ./do-something

^CSIGINT
SIGINT

Environment

  • npm: 8.12.1
  • Node.js: 16.13.1
  • OS Name: macOS
  • System Model Name: Monterey

alesmenzel avatar Jun 15 '22 08:06 alesmenzel

Same issue here, with npx ts-node

image

mashirozx avatar Jun 21 '22 08:06 mashirozx

I am not sure if this is the same issue, but I encountered double process termination prompts. It happens on some node/npm versions, but doesn't on others

I encounter this in different projects, for example let's take boilerplate vite project https://vitejs.dev/guide/

Reproduction: 0. Node v21.6.1, nvm v10.2.4

  1. yarn create vite or pnpm create vite to install. This bug is NOT happening when the project is installed through npm
  2. npm run dev
  3. Ctrl+C
  4. Two "terminate batch" promps image

This also is happening on:

  1. Node v20.11.0, npm v10.2.4
  2. Node v18.19.0, npm v10.2.3

This is not happening on:

  1. Node v19.8.1, npm v9.5.1

System is Windows 11. I use nvm for windows as node version manager, not sure if it causes mess with npm versions

vladkrasn avatar Feb 13 '24 16:02 vladkrasn