[BUG] Backend claude process and its MCP/socat children are not terminated on tab close, session resume, or project deletion — leading to unbounded process accumulation.

Open 💬 0 comments Opened Jul 9, 2026 by kyuewang17

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?

The VS Code Claude Code extension does not terminate the backend claude process (native-binary) — nor its child processes (stdio MCP servers, socat bridge) — when a chat tab/window is closed, when a session is resumed, or when the associated project directory is deleted.

Over ~1 hour of normal usage (opening/closing tabs, resuming sessions, one auto-update of an MCP server binary), the number of live backend claude processes grew to 6, each with its own child MCP server + socat process — none were ever torn down:

​``
PID(claude) PPID(ext.host) STARTED ARGS (relevant) CHILDREN
146927 145677 16:37:12 (fresh session) mcp-server-a (147249), socat (147287)
147914 145677 16:37:24 --resume 909997d8-... mcp-server-a (147957), socat (147992)
173711 172425 17:03:20 (fresh session) mcp-server-a (173990), socat (174026)
177148 172425 17:04:17 --resume f9aef7ad-... mcp-server-a (177189), socat (177222)
177333 172425 17:04:21 --resume e0a5c130-... mcp-server-a (177375), socat (177408)
227358 172425 17:35:54 (fresh session) mcp-server-a (227406), socat (227467)
``

(mcp-server-a here is a stdio MCP server configured in my ~/.claude.json; any long-lived stdio MCP server would show the same pattern.)

Key observations:

  • All 6 claude processes are still alive and consuming resources (confirmed via ps -eo pid,ppid,lstart,etime,cmd). These are not orphans reparented to PID 1 — they are legitimate live children of two separate extension-host processes (145677, 172425). The extension host itself simply never terminates them.
  • Two of the sessions (146927/147914, both under extension host 145677) are bound, via their MCP server's open file descriptors, to a project directory that has since been deleted. lsof shows the child MCP server still holding (deleted) file handles for that removed directory — the corresponding tab/window was closed (or the project removed) well before the backend process and its MCP child were cleaned up. They simply keep running with no useful purpose.
  • Within extension host 172425, three separate claude backend processes were spawned within ~65 seconds of each other (17:03:20, 17:04:17, 17:04:21), two of them via --resume <session-id> of what looks like the same session lineage. The earlier process in each case was not terminated before the resumed one was spawned, resulting in two or three live backends for what the user experiences as a single continuous conversation.

Individually each leaked process is small (tens of MB RSS, near-zero CPU while idle), but the leak is unbounded — it grows with every tab/window/session-resume cycle and is never reclaimed except by fully restarting VS Code (killing all extension hosts). On a long-running dev machine this is a real resource-exhaustion risk (I noticed the process count creeping up over a single day of normal usage).

What Should Happen?

  • Closing a chat tab/window should terminate its corresponding claude backend process and all of its children (MCP stdio servers, socat bridge).
  • Resuming a session (--resume <id>) should replace/terminate the previous backend process for that session id, not run alongside it.
  • If a project's directory is deleted or becomes unreachable, any backend process bound to it should be detected as stale and terminated, or at minimum the extension should not keep holding processes/file handles against a path that no longer exists.

Error Messages/Logs

None — no crash, no error surfaced in the UI or in the extension's output channel. The processes just accumulate silently in the background.

Steps to Reproduce

  1. Configure at least one stdio MCP server in ~/.claude.json (mcpServers.<name>.command) so each claude backend session spawns a visible long-lived child process.
  2. Open a project in VS Code and start a Claude Code chat session.
  3. Note the resulting process tree:

​``
ps -eo pid,ppid,lstart,etime,cmd | grep -E 'native-binary/claude| serve'
`
You should see one
claude` backend process plus its MCP server child(ren).

  1. Close the chat tab (or close the VS Code window) without explicitly ending the session.
  2. Re-run the same ps command. The claude backend process and its MCP server child are still present and running, with no corresponding visible tab/window.
  3. Repeat steps 2–4 a few times over the course of normal usage (opening new tabs, resuming previous sessions via history, occasionally deleting/moving a project folder that had an open session).
  4. Observe that the count of live claude backend + MCP child + socat processes only grows — it never decreases — even though the number of actually-open tabs/windows stays constant or shrinks.

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.205

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

VS Code integrated terminal

Additional Information

_No response_

View original on GitHub ↗