Drain stdin in generated hook commands to avoid BrokenPipeError#494
Open
LeonCode2025 wants to merge 2 commits into
Open
Drain stdin in generated hook commands to avoid BrokenPipeError#494LeonCode2025 wants to merge 2 commits into
LeonCode2025 wants to merge 2 commits into
Conversation
…odex-posttooluse-hook Consume stdin in generated hook commands to avoid BrokenPipeError
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.
Summary
Fixes #493.
Generated Codex and Claude hook commands currently do not consume hook event JSON from stdin before running
code-review-graphcommands. When a hook event contains a large payload, the hook command can exit successfully while the caller is still writing stdin, which causesBroken pipe/EPIPEerrors in Codex.This PR makes the generated hook commands explicitly drain stdin before running the existing git and
code-review-graphcommands.Changes
cat >/dev/null || true;cat >/dev/null || true;PostToolUseandSessionStartgenerated commandsPostToolUsecommand and verifies it exits successfully withoutBrokenPipeErrorWhy
The hook command itself may still return exit code
0, but the parent process can fail while writing hook stdin if the hook exits before consuming the payload. Draining stdin keeps the hook behavior non-blocking while avoiding the caller-side broken pipe error.Cursor/Gemini hook scripts already consume stdin, so this also makes the Codex/Claude generated hooks consistent with the existing integrations.
Testing
pytest tests/test_skills.py0and noBrokenPipeError