codex-plugin-cc
codex-plugin-cc copied to clipboard
fix: bound Stop hook stdin read so disabled gate cannot hang on Windows (#530)
Summary
Fixes #530. stop-review-gate-hook.mjs used fs.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 when stopReviewGate was already false.
Changes:
- Resolve config from
CLAUDE_PROJECT_DIR/ cwd first and take a short timed stdin read when the gate is off - Shared
readHookInput(timeoutMs)helper for boundeddata/endcollection - When the gate is on, still read stdin with a 30s bound instead of an unbounded sync read
Related 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
node --test --test-name-pattern "stop hook logs running|stdin never|..." tests/runtime.test.mjs
pass: stop hook logs running tasks to stderr without blocking when the review gate is disabled
pass: stop hook with disabled gate exits quickly when stdin never receives EOF
pass: stop hook allows the stop when the review gate is enabled and the stop-time review task is clean
3 pass, 0 fail
AI assistance
Assisted by Cursor/Grok. Human author: Stan Shih (@stantheman0128). I reviewed the diff and ran the tests above.