fix(hooks): close stdin when EOF timeout expires - #889
Merged
Merged
Conversation
|
No findings. The PR description includes sufficient testing for this runtime behavior change, including a representative real-CLI E2E result. |
jeff-r2026
approved these changes
Sep 29, 2026
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
hook-dispatchreturns from its stdin read after 1 second when a host does not send EOF, but the pendingfor await (process.stdin)loop remains attached. An open host pipe can keep the process alive after dispatch finishes, defeating the bounded read.Destroy the stdin stream only when the EOF deadline wins. Normal EOF and TTY paths remain unchanged. The regression test verifies that the buffered payload is returned and the timed-out pipe is closed.
Validation
npx vitest run src/__tests__/hook-dispatch-cli.test.ts -t "closes a pipe"— passed (1 test).npm run typecheck— passed.npm run lint— passed.npm run build— passed.{}tonode dist/index.js hook-dispatch stdin-timeout-probe --tool claude, kept the parent pipe open, and the CLI exited with code 0 in 1.9 seconds.hook-dispatch-cli.test.tsrun on this Windows host reported 18 passed and 2 timeouts in the existinghookDispatchClitests that wait for a mocked PowerShell/WMI close event; the new stdin timeout regression test passed.