Skip to content

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

Open
naveentehrpariya wants to merge 1 commit into
tinylibs:mainfrom
naveentehrpariya:fix-throw-on-signal-kill
Open

fix: throw NonZeroExitError when process is killed by signal#146
naveentehrpariya wants to merge 1 commit into
tinylibs:mainfrom
naveentehrpariya:fix-throw-on-signal-kill

Conversation

@naveentehrpariya

Copy link
Copy Markdown

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

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

1 participant