Commit 17ec70d
fix: replace blocking PostToolUse hook deferral with non-blocking fire-and-stash
Wire protocol log analysis revealed the 5-second blocking Promise.race
timeout was counterproductive for subagent child tool uses, where the
callback registration arrives 10-60+ seconds after the hook fires (when
the subagent finishes and its messages are relayed). The old code blocked
the SDK for 5 seconds per subagent tool use before timing out anyway —
strictly worse than the pre-fix behavior of logging an error and
returning immediately.
Replace with a fire-and-stash model: when the hook fires before its
callback is registered, stash the hook's input data and return
immediately. When registerHookCallback() later runs (next tick for the
42ms race condition, or seconds later for subagents), it finds the stash
and executes the callback with the original input data.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent df588d1 commit 17ec70d
2 files changed
+306
-109
lines changed
0 commit comments