Skip to content

[BUG] Signals not propagated when the script uses shell syntax #5776

@segevfiner

Description

@segevfiner

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

If you have a script that uses shell syntax, npm will not terminate the underlying script if you send it SIGTERM. This is likely due to the shell that is started in the middle not propagating signals. But I couldn't find any docs as to when npm uses or doesn't use a shell, and if this behavior is expected and had to spend a long time figuring this out.

P.S. This is likely broken with yarn 1.x and I have no idea what yarn 2.x+ does. pnpm likely has similar behavior to npm.

Expected Behavior

For this to either just work even when using shell syntax, or for this to at least be documented as a caveat with possible workarounds.

Steps To Reproduce

  1. git clone https://github.com/segevfiner/npm-signals-issue.git
  2. cd npm-signals-issue
  3. npm i
  4. npm start child1 - The server will end successfully.
  5. npm start child2 - The server will remain running, check, netstat, lsof, and so on.

Environment

  • npm: 8.19.2
  • Node.js: v16.18.0
  • OS Name: macOS 12.6.1
  • System Model Name: Macbook Pro (M1)
  • npm config:
; "user" config from /Users/segevfiner/.npmrc

//registry.npmjs.org/:_authToken = (protected)

; node bin location = /Users/segevfiner/.nvm/versions/node/v16.18.0/bin/node
; node version = v16.18.0
; npm local prefix = /Users/segevfiner/junk/npm-signals
; npm version = 8.19.2
; cwd = /Users/segevfiner/junk/npm-signals
; HOME = /Users/segevfiner
; Run `npm config ls -l` to show all defaults.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next stepsRelease 8.xwork is associated with a specific npm 8 releasesignals

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions