[BUG] VSCode Extension: Multiple extension host restarts cause orphaned processes and 100% CPU usage
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?
When VSCode Extension Host crashes or restarts, Claude Code processes and their child MCP server processes become orphaned and continue running. Over time, this leads to:
- Multiple Claude Code processes (4+ instances) running simultaneously
- Dozens of orphaned MCP server processes (40+ in our case)
- 100% CPU usage by some orphaned processes
- High memory consumption (3GB+ total)
What Should Happen?
- When Extension Host restarts, all child processes (claude code binary + MCP servers) should be properly terminated
- Only one set of claude code + MCP server processes should run per active VSCode session
- Process cleanup should happen automatically on Extension Host crash/restart
Error Messages/Logs
From VSCode Extension Host logs:
2025-12-18 01:01:51.884 [error] Error processing client request: Error: Timeout waiting after 1000ms
Multiple "Timeout waiting" errors found across 4 different Extension Host instances (exthost1-4).
Evidence
Process listing showing orphaned instances:
# Multiple claude code processes from different times
PID 82960 100.0% CPU Started: Thu Dec 18 02:14:20 2025 # Orphaned, 100% CPU
PID 80714 6.2% CPU Started: Thu Dec 18 02:00:47 2025 # Current session
PID 68021 0.0% CPU Started: Thu Dec 18 01:02:10 2025 # Orphaned
PID 67191 0.0% CPU Started: Thu Dec 18 01:02:02 2025 # Orphaned
# Each process has 10+ MCP servers
# Total: 40+ orphaned MCP server processes
VSCode Extension Host logs show multiple instances:
$ ls ~/.vscode-server/data/logs/20251217T190718/
exthost1/Anthropic.claude-code/
exthost2/Anthropic.claude-code/
exthost3/Anthropic.claude-code/
exthost4/Anthropic.claude-code/
Steps to Reproduce
- Use Claude Code VSCode extension with multiple MCP servers configured (~10+ servers)
- Experience network instability or Extension Host crash/restart
- Check running processes:
ps aux | grep claude - Observe multiple claude code processes and dozens of MCP server processes
- Some processes will consume 100% CPU indefinitely
Root Cause Analysis
- VSCode Extension Host crashes/restarts (due to network issues, memory pressure, etc.)
- New Extension Host starts, launches new claude code + MCP servers
- Old claude code and MCP server processes are NOT terminated
- Over time, orphaned processes accumulate
- Some orphaned processes enter infinite loops (busy-polling, similar to #11473)
Configuration
MCP Servers (10+):
- Notion, Google Drive, Playwright, Puppeteer, Chrome DevTools
- Tavily, Exa, Figma, PostgreSQL, sqlite-explorer
- GitHub, VSCode integration
Each Extension Host instance spawns all MCP servers, so 4 Extension Hosts = 40+ MCP processes.
Claude Model
Sonnet (default)
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
v2.0.73
Platform
VSCode Extension (vscode-server on remote macOS)
Operating System
macOS 25.1.0 (Darwin)
Terminal/Shell
VSCode Terminal (remote)
Additional Information
Workaround:
# Kill orphaned claude code processes (DANGEROUS - check before running)
ps aux | grep "anthropic.claude-code" | grep -v grep | awk '{print $2}' | xargs kill -9
# Kill orphaned MCP servers
ps aux | grep "claude mcp serve" | grep -v grep | awk '{print $2}' | xargs kill -9
Suggested Fix:
- Add process cleanup logic when Extension Host detects previous instance crashed
- Store PIDs of child processes and clean them up on startup
- Add watchdog to detect and kill orphaned processes automatically
- Improve error handling for "Timeout waiting" errors that trigger restarts
This issue is distinct from #11473 (busy-polling) and #13674 (64 TCP connections) as it's specifically about orphaned process accumulation in VSCode extension environment.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗