[BUG] PreToolUse hook that writes to workspace file causes streaming to stall in VSCode extension (not reproducible in CLI)

Resolved 💬 6 comments Opened Feb 23, 2026 by TanakaSeiji Closed Mar 28, 2026

Environment

  • Claude Code: VSCode Extension v2.1.49
  • OS: Windows 11 Home 10.0.26200
  • Shell: bash (MINGW64 / Git Bash)

Summary

PreToolUse hookがworkspaceのファイルに書き込むと、2〜3回のツール呼び出し後にストリーミングが詰まる(応答が1文字ずつ届く)。CLIでは再現しない。

Minimal Configuration

"PreToolUse": [{
  "matcher": ".*",
  "hooks": [{"type": "command", "command": "bash ./my-hook.sh", "timeout": 10}]
}]
# my-hook.sh — writes to a file inside the workspace
echo "$(date)" >> ./log/session.log

Systematic Test Results

| Hook command | Writes to | Result |
|---|---|---|
| bash -c 'exit 0' | nothing | ✅ Streaming normal |
| script + write to /dev/null | /dev/null | ✅ Streaming normal |
| script + write to ./log/session.log | workspace file | ❌ Streaming clogs after 2nd–3rd call |
| same config in CLI | workspace file | ✅ Streaming normal |

Key Finding

Writing to /dev/null instead of the workspace file eliminates the clog. The same hook in CLI mode does not cause any streaming issues.

This suggests the VSCode extension performs some blocking operation in response to workspace file changes triggered by a PreToolUse hook, which interferes with response streaming.

Also tested

  • async: true on the hook: clogs after 2nd call (slightly improved but not fixed)
  • Removing async: true (sync): clogs after 3rd call (slightly better, same root cause)
  • Replacing the script with bash -c 'exit 0': no clog

Expected Behavior

Hook file writes should not interfere with response streaming.

View original on GitHub ↗

This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗