[BUG] VS Code terminal randomly interrupts Claude Code + node process hangs + EBUSY on debug files (Windows)

Resolved 💬 4 comments Opened Nov 15, 2025 by SERGIUSH-UA Closed Nov 17, 2025

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Summary

When running Claude Code CLI in VS Code integrated terminal on Windows, three critical issues occur:

  1. Random interrupts every ~3rd agent response (shows "[Request interrupted by user]" without user input)
  2. Process hangs after closing terminal (node.exe stays running)
  3. EBUSY crash when killing hung process due to debug file locking conflict

IMPORTANT: These issues do NOT occur in:

  • External PowerShell/CMD terminal ✅ Works fine
  • Claude Code VS Code Extension ✅ Works fine
  • ONLY happens: Claude Code CLI in VS Code integrated terminal ❌

Steps to Reproduce

Issue 1: Random Interrupts (every ~3rd response)

  1. Open VS Code on Windows
  2. Open integrated terminal (PowerShell)
  3. Run claude or claude --dangerously-skip-permissions
  4. Start conversation with agent
  5. Observe: Every ~3rd agent response gets automatically interrupted
  6. Terminal shows: [Request interrupted by user] multiple times
  7. User did NOT press Escape or any interrupt key

Example from actual session:

User: [asks question]
[Request interrupted by user]
[Request interrupted by user]
[Request interrupted by user]
[Request interrupted by user]
[Request interrupted by user]

Issue 2: Process Hang + EBUSY

  1. Continue from above OR start fresh Claude CLI session in VS Code terminal
  2. Close terminal window (without proper exit via Ctrl+C or exit)
  3. Open Task Manager → node.exe process still running (PID visible)
  4. Kill node.exe via Task Manager
  5. Process automatically restarts
  6. Crash with EBUSY error

Expected Behavior

  • ✅ Claude Code should not interrupt unless user explicitly presses Escape
  • ✅ Node process should terminate cleanly when terminal is closed
  • ✅ No file locking conflicts on debug files
  • ✅ Should work the same as in external terminal

Actual Behavior

Random Interrupts

Terminal shows repeated interrupts without user input:

[Request interrupted by user]
[Request interrupted by user]
[Request interrupted by user]

Frequency: approximately every 3rd agent response

EBUSY Error

node:fs:2425
    return binding.writeFileUtf8(
                   ^

Error: EBUSY: resource busy or locked, open 'C:\Users\alter\.claude\debug\2614f9dd-e6f2-4131-85a7-f52ddb36b31e.txt'
    at Object.writeFileSync (node:fs:2425:20)
    at Module.appendFileSync (node:fs:2507:6)
    at Object.appendFileSync (file:///C:/Users/alter/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:9:1036)
    at g (file:///C:/Users/alter/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:11:87)
    at TT0 (file:///C:/Users/alter/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:91:343)
    at file:///C:/Users/alter/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3857:34974
    at Q (file:///C:/Users/alter/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:8:6501)
    at O6I (file:///C:/Users/alter/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:4121:1647)
    at S6I (file:///C:/Users/alter/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:4179:13473) {
  errno: -4082,
  code: 'EBUSY',
  syscall: 'open',
  path: 'C:\\Users\\alter\\.claude\\debug\\2614f9dd-e6f2-4131-85a7-f52ddb36b31e.txt'
}

Environment

Software Versions

  • Claude Code CLI: 2.0.42
  • Node.js: v22.18.0
  • VS Code: 1.2.4 (a8e95743c5268be73767c46944a71f4465d05c90, x64)
  • Shell: PowerShell 7 (pwsh.exe)
  • OS: Windows (exact version needed)

VS Code Terminal Configuration

Process ID (PID): 28720
Command line: C:\Program Files\PowerShell\7\pwsh.exe -noexit -command 'try { . "c:\Users\alter\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\contrib\terminal\common\scripts\shellIntegration.ps1" } catch {}'

Shell type: pwsh
Shell integration: Rich
Current working directory: E:\Projects\1c-processor-generator

Extensions Contributing to Terminal Environment

CRITICAL: Multiple extensions modify the terminal environment:

  1. Claude Code for VS Code ⚠️ (likely source of conflict)
  2. Git (enables git auth provider)
  3. Python Debugger (enables debugpy commands)
  4. GitHub Copilot Chat (enables copilot commands)
  5. Python

Timeline

  • Started happening after latest VS Code update
  • Issue frequency: ~33% of agent responses get interrupted
  • EBUSY error: 100% reproducible after killing hung process

Root Cause Analysis

Hypothesis: Extension Conflict

The Claude Code for VS Code extension modifies the terminal environment, which appears to conflict with the Claude Code CLI when both run in the same VS Code integrated terminal.

Evidence:

  1. ✅ Works perfectly in external terminal (no VS Code extension environment)
  2. ✅ Works perfectly using VS Code extension directly (no CLI in terminal)
  3. ❌ Fails ONLY when running CLI in VS Code integrated terminal (both present)

Likely mechanism:

  • VS Code extension injects shell integration scripts
  • These scripts intercept stdin/stdout/stderr
  • Spurious Escape/interrupt signals sent to CLI process
  • Terminal close events not properly propagated to child processes
  • Multiple process instances race to write debug files

Technical Details

Random interrupts: VS Code shell integration may be sending \x1b (Escape) sequences or SIGINT signals to the Claude CLI process, possibly triggered by:

  • Extension status updates
  • Terminal rendering events
  • Shell integration sequence processing (mentions "Seen sequences: P, A, B")

Process hang: VS Code terminal close doesn't send proper SIGHUP/SIGTERM to node.exe child processes when shell integration is active.

EBUSY error: appendFileSync() has no file locking mechanism, causing race condition when auto-restart creates second process instance.

Workaround

Option 1: Use External Terminal (Recommended)

# Open Windows Terminal or PowerShell separately, not VS Code integrated terminal
claude

Result: ✅ Works perfectly, no interrupts, no hangs

Option 2: Use VS Code Extension Instead

Use the Claude Code extension in VS Code sidebar instead of CLI in terminal.
Result: ✅ Works perfectly

Option 3: Disable Shell Integration (Not tested)

In VS Code settings:

{
  "terminal.integrated.shellIntegration.enabled": false
}

Related Issues

  • #11157 - Terminal relaunch prompts after extension update
  • #3068 - Claude Code kills itself when using pkill node
  • #9143 - EBUSY errors on Windows with cache files
  • #252909 (VS Code repo) - Multiple VS Code instances with terminal extensions cause crashes

Suggested Fixes

Short-term

  1. Detect VS Code environment: When Claude CLI detects it's running in VS Code integrated terminal with Claude extension present, show warning:

``
⚠️ Warning: Running Claude CLI in VS Code terminal may cause conflicts.
Recommendation: Use external terminal or Claude Code VS Code extension instead.
``

  1. Fix EBUSY: Replace appendFileSync() with async file operations + file locking + retry logic
  1. Fix interrupt handling: Add debouncing/validation for interrupt signals from VS Code terminal

Long-term

  1. Coordinate with VS Code team: Report shell integration issues with child process signal handling
  2. Extension coordination: Claude VS Code extension should detect if CLI is running in terminal and adjust behavior
  3. Process lifecycle: Properly handle terminal close events and cleanup child processes
  4. Debug file locking: Implement proper file locking mechanism for debug files on Windows

Additional Notes

  • This is a regression introduced after recent VS Code update
  • Affects Windows users specifically (Linux/macOS status unknown)
  • Critical for users who prefer CLI workflow in VS Code
  • Significantly impacts usability: ~33% interrupt rate makes CLI nearly unusable in VS Code terminal

What Should Happen?

-

Error Messages/Logs

node:fs:2425
    return binding.writeFileUtf8(
                   ^

Error: EBUSY: resource busy or locked, open 'C:\Users\alter\.claude\debug\2614f9dd-e6f2-4131-85a7-f52ddb36b31e.txt'
    at Object.writeFileSync (node:fs:2425:20)
    at Module.appendFileSync (node:fs:2507:6)
    at Object.appendFileSync (file:///C:/Users/alter/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:9:1036)
    at g (file:///C:/Users/alter/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:11:87)
    at TT0 (file:///C:/Users/alter/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:91:343)
    at file:///C:/Users/alter/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:3857:34974
    at Q (file:///C:/Users/alter/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:8:6501)
    at O6I (file:///C:/Users/alter/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:4121:1647)
    at S6I (file:///C:/Users/alter/AppData/Roaming/npm/node_modules/@anthropic-ai/claude-code/cli.js:4179:13473) {
  errno: -4082,
  code: 'EBUSY',
  syscall: 'open',
  path: 'C:\\Users\\alter\\.claude\\debug\\2614f9dd-e6f2-4131-85a7-f52ddb36b31e.txt'
}

Steps to Reproduce

-

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

_No response_

Claude Code Version

2.0.42

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

VS Code integrated terminal

Additional Information

_No response_

View original on GitHub ↗

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