Skip to content

fix(hooks): keep a hook's broken pipe from crashing the run - #994

Merged
brianjfox merged 1 commit into
mainfrom
fix-hook-payload-broken-pipe
Sep 13, 2026
Merged

fix(hooks): keep a hook's broken pipe from crashing the run#994
brianjfox merged 1 commit into
mainfrom
fix-hook-payload-broken-pipe

Conversation

@brianjfox

Copy link
Copy Markdown
Collaborator

Summary

  • Awaits the write of a lifecycle hook's payload to its stdin, inside a try.
  • Records a broken pipe — the hook exited without reading its payload — as that hook's outcome, on its exit status, instead of letting the unhandled rejection take the process down at the end of a finished run.
  • Adds a test: a shell hook that handles only postTurn is dispatched a postRun summary larger than the pipe buffers; no unhandled rejection, no hook error logged, exit status recorded. Fails on the unfixed runner, passes on the fixed one, ten runs out of ten.

Verification

  • bun run typecheck, bun run build, and bun run lint pass
  • bun run test does not complete on this machine on origin/main either: Bun 1.3.13 segfaults partway through the suite (panic: Segmentation fault at address 0x5, SIGTRAP) with or without this branch. bun test src/session/hooks.test.ts passes.
  • Reproduced the crash on 0.3.24 with an 89-turn corbits exec run whose hook handled only postTurn: the final summary printed, then EPIPE: broken pipe, send as an unhandled rejection, exit 1, run.json left at running.

Fixes #993

The payload was written to a lifecycle hook's stdin without awaiting the
write. A shell hook that handles one lifecycle kind exits at once on the
other, closing its end of the pipe; a run summary larger than the pipe
buffers, as a long session's is, then fails with EPIPE, and the
unhandled rejection took the process down at the end of a finished run.
The write is awaited, a broken pipe is recorded as the hook's outcome,
and the run ends as it did.
@brianjfox
brianjfox merged commit f035c7c into main Sep 13, 2026
9 checks passed
@brianjfox
brianjfox deleted the fix-hook-payload-broken-pipe branch September 13, 2026 19:38
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.

A hook that exits without reading its payload crashes corbits exec at the end of a long run

1 participant