anthropics / anthropics/claude-code

[BUG] VS Code extension: closing a session tab (×) leaves the claude process and its MCP servers running

Offen
#94,292 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
area:ide area:mcp bug has repro platform:linux platform:vscode
Vorherrschende Sprache
Python
Sterne
145k
Forks
23.1k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

## Summary

In the VS Code extension, closing a Claude Code tab with the tab's **×** does not terminate the underlying `claude` process. The process keeps running (with its stdio MCP servers) until VS Code exits. Blank "new session" views that never received a prompt are affected too, so every opened-then-closed tab leaks a full `claude` process.

## Environment

- Claude Code VS Code extension `2.1.270` (`anthropic.claude-code-2.1.270-linux-x64`), native binary
- VS Code `1.137.0`
- Kubuntu 26.04.1 (Linux 7.0), Node 22.23.1 via nvm
- `permissions.defaultMode: bypassPermissions`, 4 stdio MCP servers at user scope (gcloud, postgres, chrome-devtools, figma) at the time of the measurement

## Steps to reproduce

1. Open the Claude Code panel in VS Code, open a new session tab (no need to type anything).
2. Close that tab with the × on the tab.
3. `ls ~/.claude/sessions/` — the `.json` for that session is still there; `ps -p ` shows the `native-binary/claude --output-format stream-json` process still alive, with its MCP child processes.

Repeat: each open/close cycle adds one process.

## What I measured

With 3 tabs actually open, I had **5** `claude` processes (two with `sessionId`s that have no transcript in `~/.claude/projects/` at all — blank views closed with ×), later **6** for 3 tabs after a window reload. Each process carried its own 4 stdio MCP servers: **66 MCP processes and ~3.5 GB RSS** for Claude Code alone (per-session trees between 260 MB and 1.2 GB).

The extension host log (`Claude VSCode.log`) for that window shows 6 `init` and 10 `launch_claude` webview messages, and **no message of any kind when a tab is closed** — no dispose/kill/close request reaches the extension side:

```
$ grep -oE '"request":\{"type":"[a-z_]+"' "Claude VSCode.log" | sort | uniq -c | sort -rn
155 webview_focused
117 update_session_state
77 rename_tab
...
6 init
$ grep -oE 'Received message from webview: \{"type":"[a-z_]+"' … | sort | uniq -c
10 launch_claude
2 interrupt_claude
```

(no `close_*`, `kill_*`, `dispose_*` entries exist)

## Expected

Closing a tab disposes the session: the `claude` process and its MCP children exit, and `~/.claude/sessions/.json` is removed. At minimum, blank views that never received a prompt should be reaped when their tab is closed.

## Actual

Process and MCP children keep running until VS Code exits. `~/.claude/sessions/.json` stays. Nothing in the UI shows these sessions, so users cannot see or close them.

## Workaround

A cron that kills `claude-vscode` sessions whose `sessionId` has no transcript and that are older than 10 minutes (reads `~/.claude/sessions/*.json`). Closed tabs that *do* have a transcript cannot be distinguished from open ones from outside, so those still leak.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.