Skip to content

[BUG] SIGINT called twice #5021

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 tasks done
alesmenzel opened this issue Jun 15, 2022 · 3 comments
Closed
2 tasks done

[BUG] SIGINT called twice #5021

alesmenzel opened this issue Jun 15, 2022 · 3 comments
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 8.x work is associated with a specific npm 8 release signals

Comments

@alesmenzel
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • 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 alesmenzel added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Jun 15, 2022
@alesmenzel alesmenzel changed the title [BUG] <title> [BUG] SIGINT called twice Jun 15, 2022
@mashirozx
Copy link

Same issue here, with npx ts-node

image

@fritzy fritzy added Priority 2 secondary priority issue and removed Needs Triage needs review for next steps labels Jun 30, 2022
@vladkrasn
Copy link

vladkrasn commented Feb 13, 2024

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

@milaninfy
Copy link
Contributor

This looks similer if not duplicate of #8164. Closing this and keeping the recent one open for better visibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug thing that needs fixing Priority 2 secondary priority issue Release 8.x work is associated with a specific npm 8 release signals
Projects
None yet
Development

No branches or pull requests

6 participants