fix(run): report a non-zero exit code when the child dies from a signal#58
Open
exo-nikita wants to merge 1 commit into
Open
fix(run): report a non-zero exit code when the child dies from a signal#58exo-nikita wants to merge 1 commit into
exo-nikita wants to merge 1 commit into
Conversation
Both CLI launchers propagated the child's exit code via `const [code] = await once(child, 'close')`, but when the child is killed by a signal (SIGSEGV, SIGKILL, OOM-kill) the 'close' event yields code=null, so `process.exitCode = null` made the launcher exit 0 -- a crashed program was reported as success. Destructure the signal too and apply the shell convention 128+signo (e.g. 137 for SIGKILL) when code is null, in both stasis-core and stasis bins. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01M16Lwt8cM1azwev94UP81X
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
Both CLI launchers (
stasis-core runandstasis run) wrap the user's program in a child process and propagate its exit code with:When the child dies from a signal (SIGSEGV, SIGKILL, OOM-kill), the
'close'event yieldscode === null, soprocess.exitCode = nulland the launcher exits 0 — a crashed program is reported as success. In CI this silently turns crashes into green builds.Repro: an entry doing
process.kill(process.pid, 'SIGKILL')run viastasis-core run --lock=ignore entry.jsexited 0, while running it undernodedirectly exits 137.The fix
Destructure the signal from the
'close'event too, and apply the shell convention128 + signowhencodeis null (e.g. 137 for SIGKILL, 139 for SIGSEGV), in both bins:Test
Added a regression test to
tests/stasis-core-cli.test.js: a tmp fixture whose entry SIGKILLs itself, run viastasis-core run --lock=ignore, asserting the reported status is exactly 137. (SIGKILL rather than SIGSEGV to avoid core-dump side effects.) No mirrored test intests/cli.test.js— thestasisbin'srunpath needs the installed@exodus/stasis-coreworkspace dep to resolve its loader, which wasn't available in the environment this was authored in; the fix itself is applied to both bins and is the identical pattern covered by the stasis-core test.Manual verification: the SIGKILL fixture exits 0 before the fix and 137 after;
--versionand the rest oftests/stasis-core-cli.test.js(10/10) still pass.🤖 Generated with Claude Code
https://claude.ai/code/session_01M16Lwt8cM1azwev94UP81X
Generated by Claude Code