fix: add timeout: null support to HookCallbackMatcher for indefinite hook waiting#194
Open
samhagman wants to merge 1 commit intoanthropics:mainfrom
Open
fix: add timeout: null support to HookCallbackMatcher for indefinite hook waiting#194samhagman wants to merge 1 commit intoanthropics:mainfrom
samhagman wants to merge 1 commit intoanthropics:mainfrom
Conversation
HookCallbackMatcher.timeout uses a truthy check in cli.js which means null, undefined, and 0 all silently fall back to the 60s default. There is no way to express "wait forever" in the TypeScript SDK, unlike the Python SDK where timeout=None achieves this. Changes: - apply-patch.mjs: patches cli.js (4 sites) and sdk.d.ts locally - restore-patch.mjs: restores .bak files - test-patch-unit.mjs: 14 unit assertions, no API key needed (14/14 pass) - test-timeout-bug.mjs: full integration repro (requires ANTHROPIC_API_KEY) - ISSUE.md: detailed bug report with proposed source-level fix - package.json / .gitignore Proposed fix in cli.js source: Before: Z.timeout ? Z.timeout*1000 : z After: Z.timeout === null ? null : Z.timeout ? Z.timeout*1000 : z + skip AbortSignal.timeout() when null, use rk(parentSignal) only Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Situation, Complication, Resolution
Situation:
HookCallbackMatcher.timeoutlets you set how long a PreToolUse hookwaits before timing out. The Python SDK supports
timeout=Nonefor "wait forever".Complication: The TypeScript SDK has no equivalent. The hook executor in
cli.jsuses a truthy check (
Z.timeout ? Z.timeout*1000 : z) which meansnull,undefined,and even
0all silently fall back to the 60-second default. Interactive hooks likeAskUserQuestionandExitPlanMode— which require a human to respond — will alwaystime out after 60 seconds with no way to opt out.
Resolution: Treat
timeout: nullas "wait indefinitely" by skippingAbortSignal.timeout()entirely at each of the 4 hook executor sites. Therk()signalcombiner already accepts an optional second argument, so
rk(parentSignal)(no timeoutsignal) works without any changes to
rkitself.Changes proposed
Since the source is not public, this PR includes:
apply-patch.mjs— patchescli.js(4 sites) andsdk.d.tsin a local installrestore-patch.mjs— restores from.bakbackupstest-patch-unit.mjs— 14 unit assertions (no API key needed); 14/14 passtest-timeout-bug.mjs— full integration repro (requiresANTHROPIC_API_KEY)ISSUE.md— detailed write-up with proposed source-level diffsProposed source change (cli.js, 4 sites)
Proposed type change (sdk.d.ts)
Test results
Python SDK parity
The TypeScript fix makes parity:
🤖 Generated with Claude Code