[BUG] VSCode extension hangs indefinitely in devcontainer — CLAUDE_CODE_SSE_PORT stale after extension restart (regression in 2.1.170)
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?
Since approximately June 9, 2026 (around v2.1.170), the Claude Code VSCode extension hangs indefinitely inside a devcontainer when sending any prompt — including a simple "hello". The UI shows a loading spinner and never receives a response. The same setup worked correctly before this release.
Root cause (confirmed via debugging)
The extension writes a lock file at ~/.claude/ide/<PORT>.lock when it starts, binding to a new port on each activation. However, the CLAUDE_CODE_SSE_PORT environment variable inherited by terminals retains an old port value from a previous extension session. The CLI process attempts to connect to the stale port, which is no longer listening, and hangs indefinitely without surfacing an error.
Concrete example from the affected environment:
Lock file present: ~/.claude/ide/33683.lock ← current port
$CLAUDE_CODE_SSE_PORT = 18901 ← stale port from previous session
The CLI connects to port 18901 (dead), times out silently, and never processes messages from the webview.
This is similar to issue #42141, but previously the env var and lock file stayed in sync. Something in the v2.1.170 release (which fixed "sessions not saving transcripts when launched from terminals that inherited Claude Code environment variables") appears to have changed how CLAUDE_CODE_SSE_PORT is propagated, causing this desync.
What Should Happen?
The CLI should connect to the port in the current lock file (33683) and respond normally. Either:
CLAUDE_CODE_SSE_PORTshould be refreshed in all terminals when the extension restarts and binds to a new port, or- The CLI should fall back to reading the current port directly from
~/.claude/ide/*.lockinstead of trusting the potentially-stale env var
Error Messages/Logs
2026-06-12 12:25:10.143 [info] From claude: [DEBUG] [mcp-registry] Loaded 294 official MCP URLs (legacy)
No MCP connection attempt to `claude-vscode`, no error, no further output.
Steps to Reproduce
- Open a project in a devcontainer (no Claude Code on the host machine)
- Let the container build and the extension activate
- Open the Claude Code panel
- Send any message (e.g. "hello")
- Observe: the UI spins indefinitely, no response is ever received
To confirm the root cause:
Inside a terminal in the container, after step 3:
# Check the current lock file port
ls ~/.claude/ide/
# e.g. → 33683.lock
# Check the env var in the terminal
echo $CLAUDE_CODE_SSE_PORT
# e.g. → 18901 ← different! this is the bug
---
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.1.170
Platform
Anthropic API
Operating System
Other Linux
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗