Skip to content

fix: throw NonZeroExitError when process is killed by signal - #146

Merged
43081j merged 2 commits into
tinylibs:mainfrom
naveentehrpariya:fix-throw-on-signal-kill
Jul 1, 2026
Merged

fix: throw NonZeroExitError when process is killed by signal#146
43081j merged 2 commits into
tinylibs:mainfrom
naveentehrpariya:fix-throw-on-signal-kill

Conversation

@naveentehrpariya

Copy link
Copy Markdown
Contributor

Summary

When a child process is killed by a signal (SIGABRT, SIGKILL, SIGTERM, etc.), throwOnError: true silently resolves instead of throwing NonZeroExitError.

Root cause: When a process dies by signal, Node.js sets child.exitCode = null and child.signalCode to the signal name. The exitCode getter returns undefined for null, and the throwOnError check excludes undefined — so signal-killed processes slip through. Same flaw exists in xSync.

Changes

  • Add signalCode to CommonOutputApi interface and ExecProcess getter
  • Fix throwOnError in _waitForOutput and async iterator to throw when signalCode != null
  • Fix xSync throwOnError to also check signalCode
  • Update NonZeroExitError message to "Process was killed with signal SIGTERM" for signal deaths; expose signalCode getter
  • Add regression tests for async and sync signal-kill paths

Fixes #144

@naveentehrpariya
naveentehrpariya force-pushed the fix-throw-on-signal-kill branch from e911f26 to a0be64d Compare June 29, 2026 07:18
@43081j
43081j force-pushed the fix-throw-on-signal-kill branch 2 times, most recently from 3402520 to ed0208c Compare July 1, 2026 11:29
@43081j
43081j force-pushed the fix-throw-on-signal-kill branch from ed0208c to 8ce8f2b Compare July 1, 2026 11:32
@43081j
43081j merged commit dc10426 into tinylibs:main Jul 1, 2026
9 checks passed
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.

throwOnError does not throw when the child is killed by a signal

2 participants