Skip to content

[BUG] ctrl-c / SIGINT does not kill npm install #5976

@everett1992

Description

@everett1992

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

Reproducible in npm 9.2.0 and 8.19.2

Killing the process with CTRL-C or sending SIGINT won't immediately kill npm. If I hit CTRL-C while the install progress bar is visible npm will continue running till the progress bar is full, including starting new http requests. Eventually npm will print

npm ERR! process terminated
npm ERR! signal SIGINT

Some excerpts from a silly log shows that npm runs for 12 seconds after the signal.

Dec 17 16:34:23 npm timing reifyNode:node_modules/esbuild-android-64 Completed in 48ms
Dec 17 16:34:23 SIGINT
Dec 17 16:34:24 npm http fetch POST 405 http://localhost:8080/-/npm/v1/security/advisories/bulk 305ms
...
Dec 17 16:34:24 npm http fetch GET 200 http://localhost:8080/rimraf 367ms (cache updated)
Dec 17 16:34:36 npm http fetch GET 200 http://localhost:8080/ansi-styles/-/ansi-styles-4.3.0.tgz 5860ms (cache updated)
Dec 17 16:34:36 npm timing reifyNode:node_modules/asse.rtion-error Completed in 12320ms
...
Dec 17 16:34:36 npm timing reify:unpack Completed in 12387ms
Dec 17 16:34:36 npm timing reify:rollback:createSparse Completed in 174ms
Dec 17 16:34:36 npm timing reify:rollback:retireShallow Completed in 11ms
Dec 17 16:34:36 npm timing command:install Completed in 12796ms
Dec 17 16:34:36 npm verb stack Error: process terminated

A second SIGINT signal will cause an immediate exit

Expected Behavior

Npm should exit soon after receiving SIGINT. If npm has to clean up after itself it should print a message - but it doesn't seem like it's cleaning up, instead it's continuing to fetch packages.

Steps To Reproduce

  1. On an Ubuntu linux computer with npm 9.2.0 or 8.19.2
  2. In a package with enough dependencies for npm install to take a while
  3. With a package-lock.json
  4. Without node_modules
  5. Run npm install
  6. Hit ctrl-c when you see the progress bar

See the progress bar continue and wait for npm to exit.

Interestingly it doesn't seem to reproduce without a package-lock.json.

Environment

  • npm: 9.2.0 (and 8.19.2)
  • Node.js: 18.12.1
  • OS Name: Ubuntu
  • System Model Name:
  • npm config:
; node version = v18.12.1
; npm local prefix = ~/example
; npm version = 8.19.2
; cwd = ~/example
; HOME = ~
; Run `npm config ls -l` to show all defaults.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingsignals

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions