cli
cli copied to clipboard
[BUG] Signals not propagated when the script uses shell syntax
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
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
git clone https://github.com/segevfiner/npm-signals-issue.gitcd npm-signals-issuenpm inpm start child1- The server will end successfully.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.