-
Notifications
You must be signed in to change notification settings - Fork 24
Closed
Description
What / Why
#9 introduced an issue whereby an error is thrown when an npm script process is terminated.
When
Consistently, following the repro below.
Where
Any project. macOS 10.15.7, Node 14.14.0, npm 7.0.6.
How
- n/a
Current Behavior
This line assumes that the callback will always be invoked with an object:
run-script/lib/signal-manager.js
Line 36 in 1c7bbcd
proc.once('exit', ({ code }) => { |
However, this is evidently not the case:
21 verbose stack TypeError: Cannot destructure property 'code' of 'object null' as it is null.
21 verbose stack at ChildProcess.<anonymous> (/Users/billy/.config/nvm/14.14.0/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/signal-manager.js:36:24)
21 verbose stack at Object.onceWrapper (events.js:422:26)
21 verbose stack at ChildProcess.emit (events.js:315:20)
21 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
Steps to Reproduce
- Create a package.json with a script
foo
that includes a long-running process. - Run
npm run foo
. - Terminate the script early, e.g., by pressing
ctrl+c
.
Expected Behavior
The process should terminate without throwing an error, or at least by throwing a more intelligible error.
Who
References
- Introduced in forward signals to children #9.
jaydenseric
Metadata
Metadata
Assignees
Labels
No labels