Skip to content

fix(hooks): ship default timeouts so a hung hook cannot block the CLI - #1228

Open
rubenmarcus wants to merge 1 commit into
mksglu:nextfrom
rubenmarcus:fix/hooks-default-timeouts
Open

rubenmarcus wants to merge 1 commit into
mksglu:nextfrom
rubenmarcus:fix/hooks-default-timeouts

Conversation

@rubenmarcus

Copy link
Copy Markdown

Fixes #1226.

The shipped hooks/hooks.json declared no timeout on any of its 14 command entries, so a hung hook script (the issue hit an infinite loop in a PreToolUse matcher) blocks the host CLI indefinitely with no permission prompt to escape. Patching a timeout into the plugin cache works until the next ctx upgrade restores the upstream file and drops it.

This ships the timeouts in the file itself: 10s for the 9 PreToolUse matchers, which sit on the critical path of every tool call, and 30s for PostToolUse, PreCompact, UserPromptSubmit, SessionStart and Stop.

tests/hooks/shipped-hooks-timeout.test.ts guards it: every command entry in the shipped file must carry a numeric timeout and PreToolUse must stay at or under 10s. RED on the previous commit (all 14 entries fail typeof timeout === "number"), GREEN on this one, 16/16.

Neighbors: the 6 failures in tests/hooks/integration.test.ts (latency marker cleanup) and friends are pre-existing, reproduced identically on the base branch (6 failed | 85 passed on base, same 6 | 101 with this branch's 16 new tests passing).

Prepared with AI assistance (GLM 5.3 via Oh My Pi) and reviewed before submission.

@rubenmarcus
rubenmarcus force-pushed the fix/hooks-default-timeouts branch 2 times, most recently from afcc588 to 23f722e Compare September 30, 2026 12:36
@rubenmarcus
rubenmarcus force-pushed the fix/hooks-default-timeouts branch from 23f722e to a8a3327 Compare September 30, 2026 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants