fix(hooks): bound foreground hook time to stay under host 10s cap - #248
Merged
Merged
Conversation
Foreground (inline) hooks block the host IDE and are aborted at ~10s
regardless of the declared timeout ("Hook timed out after 10000ms",
error 3003). Add layered bounds so a slow/unreachable endpoint or a
missing STDIN EOF can never trip that ceiling:
- hook-handlers: unify every foreground handler timeout to 4.5s;
detached background handlers keep their full budget.
- local-agent: cap per-fetch timeout at 3s inside foreground hooks
(SessionStart/UserPromptSubmit); background runs keep 15s.
- hook-dispatch-cli: readStdin races a 2s deadline so a host that
writes the payload but never sends EOF no longer hangs the process.
- index: 7s hard-exit safety net for the foreground hook process; the
detached --bg-only child is exempt and keeps its full budget.
Add regression tests asserting all foreground handler timeouts stay
under 5s.
jeff-r2026
force-pushed
the
fix/hook-foreground-timeout
branch
from
July 28, 2026 02:52
69b0ceb to
c71f574
Compare
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.
Problem
Foreground (inline) hooks block the host IDE and are aborted at ~10s regardless of the declared timeout — even Stop/SessionStart (declared 15s) are killed at 10000ms, reporting
Hook timed out after 10000ms(error 3003) and breaking the IDE. Two paths could hit this:local-agentreport/sync) in a foreground handler.readStdin'sfor await (process.stdin)hanging forever when the host writes the payload but never sends EOF — this happens before any handler timeout can engage.Changes (layered bounds)
FOREGROUND_HOOK_TIMEOUT_MS); detached background handlers keep their full budget.readStdinraces a 2s deadline — a host that writes the payload but never sends EOF no longer hangs the process; we proceed with the buffered payload.--bg-onlychild is exempt and keeps its full budget.Healthy endpoints answer well under a second, so these bounds are invisible in normal use; they only cap the worst case.
Tests
Added regression tests asserting every foreground handler timeout stays under 5s and that foreground local-agent-sync timeouts are unified.
npm run build+vitest(hook-handlers 21 + local-agent 38) all green.