[BUG] Signals not propagated when the script uses shell syntax
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
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
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked npm-signals-issue reproduction and run the listed npm start child1 and npm start child2 commands to compare signal handling. The payload names no npm CLI files or tests; done would mean either terminating the underlying script when SIGTERM is sent or documenting the shell-syntax caveat and workarounds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs, shell
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100