fix: bound Stop hook stdin read so disabled gate cannot hang on Windows (#530)#544
fix: bound Stop hook stdin read so disabled gate cannot hang on Windows (#530)#544stantheman0128 wants to merge 1 commit into
Conversation
fs.readFileSync(0) waits for EOF. On Windows Claude Code may leave the pipe open, so the Stop hook hit the 900s timeout even when stopReviewGate was false. Check config from cwd/env first and use a timed stdin reader (openai#530). Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5bb448044d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if (!preliminaryConfig.stopReviewGate) { | ||
| const input = await readHookInput(DISABLED_GATE_STDIN_TIMEOUT_MS); |
There was a problem hiding this comment.
Re-check the gate for stdin.cwd before returning
When the hook is launched without CLAUDE_PROJECT_DIR or from a different working directory than the project in the hook payload, this early return trusts the config for cwdGuess. The subsequent short read may discover input.cwd, but the branch only logs running tasks and returns, so a project whose payload cwd has stopReviewGate: true can stop without running the review gate. This regresses the previous behavior, which loaded config after reading input.cwd; re-check the actual workspace's config before deciding the gate is disabled.
Useful? React with 👍 / 👎.
Summary
Fixes #530.
stop-review-gate-hook.mjsusedfs.readFileSync(0), which blocks until stdin EOF. On Windows, Claude Code can leave the write end open after sending the Stop payload, so the hook sat until the 900s hook timeout even whenstopReviewGatewas already false.Changes:
CLAUDE_PROJECT_DIR/ cwd first and take a short timed stdin read when the gate is offreadHookInput(timeoutMs)helper for boundeddata/endcollectionRelated open EAGAIN PRs (#123/#132/#165) target #120 (non-blocking EAGAIN throws). This is a different failure mode: missing EOF with a disabled gate.
Evidence
AI assistance
Assisted by Cursor/Grok. Human author: Stan Shih (@stantheman0128). I reviewed the diff and ran the tests above.