[BUG] VSCode Extension: Multiple extension host restarts cause orphaned processes and 100% CPU usage

Resolved 💬 3 comments Opened Dec 18, 2025 by kouiso Closed Dec 22, 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?

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:

  1. Multiple Claude Code processes (4+ instances) running simultaneously
  2. Dozens of orphaned MCP server processes (40+ in our case)
  3. 100% CPU usage by some orphaned processes
  4. 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

  1. Use Claude Code VSCode extension with multiple MCP servers configured (~10+ servers)
  2. Experience network instability or Extension Host crash/restart
  3. Check running processes: ps aux | grep claude
  4. Observe multiple claude code processes and dozens of MCP server processes
  5. Some processes will consume 100% CPU indefinitely

Root Cause Analysis

  1. VSCode Extension Host crashes/restarts (due to network issues, memory pressure, etc.)
  2. New Extension Host starts, launches new claude code + MCP servers
  3. Old claude code and MCP server processes are NOT terminated
  4. Over time, orphaned processes accumulate
  5. 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:

  1. Add process cleanup logic when Extension Host detects previous instance crashed
  2. Store PIDs of child processes and clean them up on startup
  3. Add watchdog to detect and kill orphaned processes automatically
  4. 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.

View original on GitHub ↗

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