Commit f992d1b
committed
fix(hooks): tolerate BrokenPipe when a post_tool hook ignores stdin
The CI test post_tool_captures_failure_stdout_and_stderr failed on Linux
(release) while passing on macOS. Root cause: run_hook_command writes the
event JSON to the hook's stdin and treated *any* write error as fatal. A
verify hook that ignores stdin and exits — a bare `cargo build` / `pytest`,
or any hook that reads the event from argv/env — closes its stdin read end
before (or while) we write. On Linux that surfaces as BrokenPipe (EPIPE)
immediately; on macOS the small event JSON fits the pipe buffer and the
write completes before the child exits.
So on Linux the write returned Err, run_post_tool_hooks logged it and
skipped the hook, and the captured failure output never reached the model —
non-deterministically losing exactly the verify-into-fix signal this feature
exists to deliver. The hook simply didn't consume the event, which is not an
error: swallow BrokenPipe on the stdin write and proceed to capture the
hook's output and exit status. Any other write error is still fatal.
The existing post_tool_captures_failure_stdout_and_stderr test (whose hook
ignores stdin and exits 1) is the regression guard; it now passes on Linux.1 parent 67d2116 commit f992d1b
1 file changed
Lines changed: 12 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
158 | | - | |
159 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
160 | 169 | | |
161 | 170 | | |
162 | 171 | | |
| |||
0 commit comments