Stop hook hangs on Windows when review gate is disabled (stdin blocking)
On Windows with Git Bash as the configured shell, the Stop hook opens a new terminal window and hangs indefinitely (up to the 900s timeout) after every Claude response, even when the review gate is disabled.
stop-review-gate-hook.mjs calls fs.readFileSync(0, "utf8") (blocking stdin read) at the top of main(), before checking whether config.stopReviewGate is enabled. On Windows with Git Bash, the hook runner does not properly pipe/close stdin for the spawned Node.js process, so the read blocks forever.
The gate check at line 154 (if (!config.stopReviewGate) { return; }) never runs because execution is stuck at line 143 (readHookInput()).
Environment:
- OS: Windows 11 Enterprise
- Shell: Git Bash (C:/Users/.../Git/usr/bin/bash.exe)
- Claude Code with Codex plugin v1.0.3
- Review gate: disabled (stopReviewGate: false)
+1 Confirming this on Windows 11 + Git Bash + plugin 1.0.3 (verified the v1.0.4 manifest is byte-identical, so still affected).
Empirical evidence
Direct manual run with echo '{}' | to provide stdin returns cleanly:
$ time (echo '{}' | node "stop-review-gate-hook.mjs")
real 0m0.644s
exit 0
Under the actual Claude Code harness (no piped stdin), the same hook hangs until the manifest's 900ms timeout, after which the harness emits:
Stop hook error: Failed with non-blocking status code: No stderr output
Signature is consistent with fs.readFileSync(0) blocking on a stdin handle the harness leaves open without writing — exactly as the original report describes.
Confirmed config
state.json:config.stopReviewGate: false- Plugin: codex 1.0.3, also tested against the v1.0.4 manifest — identical
5 / 5 / 900timeouts inhooks/hooks.json.
Suggested fix directions
-
Primary (matches root cause): move
readHookInput()to after theconfig.stopReviewGatecheck at line 154. When the gate is off, the script can short-circuit without reading stdin at all. This eliminates the hang in the common (default) case. -
Defensive alternative: non-blocking stdin read with a short fallback — e.g.
Promise.racebetween an event-based stdin reader andsetTimeout(50, () => ({})). Useful if any future code path needs the input even when the gate is off. -
Orthogonal but related: the manifest timeouts in
plugins/codex/hooks/hooks.jsonlook like they assume seconds:"SessionStart": ... "timeout": 5 // 5 ms — unreachable for a Node cold start "SessionEnd": ... "timeout": 5 // 5 ms — same "Stop": ... "timeout": 900 // 900 ms — barely above the empirical 644msPer the CC schema,
command/httphook timeouts are in milliseconds. SessionStart/End at 5ms cannot succeed under any realistic conditions. Suggest bumping to5000 / 5000 / 10000regardless of the stdin fix — those are independent bugs.
Happy to test a candidate patch on Windows 11 + Git Bash if it helps land the fix.
Duplicate of #530.