You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
node --run should find a way to avoid keeping a shell around and properly forward signals #65712
Node has gained node --run as a way to directly execute a package.json script, but this has a glaring subtle limitation currently that has bitten me and likely others, and is also recurring in the existing package managers: It doesn't forward signals properly to the subprocess, and the shell in the middle can even end up swallowing those signals and lingering when invoked node --run is invoked as PID 1 in Docker.
What is the feature you are proposing to solve the problem?
It would be much nicer to have a variant that can function identically to just a direct node script.js invocation, but with the arguments and command line in the package.json for DRY reasons. This can be problematic though, as package.json scripts are currently arbitrary shell scripts, and Node.js likely just uses sh to execute them rather then any JS shell-emulator (Pnpm, Yarn), which can limit it's ability to directly exec the final ran command so the shell in the middle doesn't swallow signals.
What alternatives have you considered?
Don't use node --run or the package mangers, just direct node script.js duplicating the start command.
I’d like to investigate how node --run currently spawns package scripts and how the intermediate shell affects signal forwarding and process lifetime, particularly when Node is running as PID 1 in a container.
I can look into whether the command can be executed without unnecessarily keeping a shell around, while preserving the existing package.json script behavior and cross-platform compatibility. I’ll also add appropriate tests covering signal propagation and child-process termination.
If the issue is available, please assign it to me. Thanks!
Activity
Shivang9983 commentedon Sep 5, 2026
Hi, @segevfiner I’d like to work on this issue.
I’d like to investigate how
node --runcurrently spawns package scripts and how the intermediate shell affects signal forwarding and process lifetime, particularly when Node is running as PID 1 in a container.I can look into whether the command can be executed without unnecessarily keeping a shell around, while preserving the existing
package.jsonscript behavior and cross-platform compatibility. I’ll also add appropriate tests covering signal propagation and child-process termination.If the issue is available, please assign it to me. Thanks!