mirror of
https://github.com/instructkr/claw-code.git
synced 2026-12-01 00:00:00 +08:00
A hook that exits without reading all of its stdin closes the pipe while CommandWithStdin::output_with_stdin is still writing the JSON payload. The write fails with BrokenPipe, and the error was propagated, so the hook was reported as "failed to start ...: Broken pipe (os error 32)" even though it ran and exited normally. A failed PreToolUse hook then denies the tool call, and a failed PostToolUse hook marks the tool result as an error. Any payload larger than the pipe buffer (64 KiB on Linux) triggers it for a hook that does not read stdin. The payload carries tool_input twice, so a write_file of about 40 KB is enough. plugins/src/hooks.rs already tolerates BrokenPipe for the same reason (ROADMAP #25). Apply the same handling to the runtime hook runner, and add a regression test.