Skip to content

fix: clean up signal handlers after failed spawns - #286

Open
yqia03 wants to merge 1 commit into
npm:mainfrom
yqia03:fix/failed-spawn-signal-cleanup
Open

yqia03 wants to merge 1 commit into
npm:mainfrom
yqia03:fix/failed-spawn-signal-cleanup

Conversation

@yqia03

@yqia03 yqia03 commented Nov 15, 2026

Copy link
Copy Markdown

When an inherited-stdio lifecycle script cannot start its configured shell, the child emits error and close without exit. The signal manager only cleans up on exit, so a caught ENOENT leaves the failed child and the SIGINT/SIGTERM forwarding listeners installed. On POSIX, a long-lived caller then loses the default termination behavior for these signals.

Keep the existing immediate cleanup on exit, and also clean up on close for failed spawns. Remove both per-child listeners when either event fires so cleanup happens once. Add a real missing-executable regression and a control showing that another running child keeps its forwarding listeners until it exits.

Validation:

  • Both new regressions fail before the fix (four listener assertions) and pass after it.
  • All five test files pass on Node.js 22.23.5 and 26.8.1, with 100% statement, branch, function, and line coverage. ESLint passes.
  • A full runScript() call with a nonexistent scriptShell and stdio: 'inherit' rejects with ENOENT both before and after. Before the fix it leaves both signal handlers installed; after the fix neither remains once the child closes.
  • npm test fails only at the final template-oss-check for five generated .github files. Untouched upstream 2385917 produces identical template-check output with the same dependencies. Generated files are unchanged.

An independent Codex agent reviewed the diff and verified normal exits, failed spawns, overlapping children, later batches, and non-terminating errors.

Authored, tested, and independently reviewed using Codex. The account owner authorized this submission but has not personally reviewed or run the change. Local verification was on macOS; native Linux/Windows results remain for CI.

References

Node.js child-process events document that a failed spawn emits close after error, while exit is not guaranteed after an error.

@yqia03
yqia03 requested a review from a team as a code owner November 15, 2026 17:46
Copilot AI balanced review requested due to automatic review settings November 15, 2026 17:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants