UI shows "Unhandled case: [object Object]" toast when SDK stream ends with error after stall
Summary
When the streaming connection to the API stalls and the SDK gives up with had_error: true, the Claude Code VS Code extension's webview shows a generic toast reading Unhandled case: [object Object] instead of a user-meaningful message. The error object is passed straight into a default switch case and serialized via implicit String(), producing [object Object].
This blocks the visible stream — from the user's perspective, Claude has stopped working, and they have to dismiss the toast (or reload the webview with Cmd+R) before the next interaction.
Environment
- OS: macOS 15 (Darwin 25.3.0), Apple Silicon
- VS Code: stable (latest)
- Claude Code extension: 2.1.141 (latest available, no update offered)
- Native binary: \
claude\2.1.141 from extension bundle - Plan: standard (fast mode unavailable: extra usage billing)
Repro steps
- Open Claude Code in VS Code, start any session
- Wait for a moment when the network/API streaming stalls (occurs intermittently, multiple times per hour in our environment — exact trigger unknown, possibly correlated with API load or local network jitter)
- Observe: stream goes silent for 15+ seconds while you're awaiting a response
- Observe: SDK eventually emits \
sdk_stream_ended_no_result\with \had_error: true\ - Observe the bug: an orange toast appears reading \
Unhandled case: [object Object]\with links \"View output logs\" and \"Troubleshooting resources\"
Expected behavior
The toast should display a meaningful, user-facing message such as:
- \"Connection stalled — retry?\" (with retry button)
- \"Stream ended unexpectedly — your message may be incomplete\"
- Anything except a serialized object placeholder
Actual behavior
Toast displays the literal string \Unhandled case: [object Object]\. No actionable information. User must dismiss the toast and either retry the request or reload the webview (\Cmd+R\ while panel has focus) to continue.
Log evidence
From \~/Library/Application Support/Code/logs/.../Anthropic.claude-code/Claude VSCode.log\:
\\\\
2026-05-14T11:58:04.535Z [WARN] [Stall] stream_idle_partial lastChunkAgeMs=15000 bytesTotal=656 idleDeadlineMs=300000
2026-05-14T11:58:19.551 webview event log_event sdk_stream_ended_no_result {had_error: true, subagent_count: 0, message_count: 74}
2026-05-14T11:58:24.785 [WARN] Streaming stall detected: 35.2s gap between events (stall #1)
2026-05-14T11:59:19.105 [WARN] Streaming completed with 1 stall(s), total stall time: 35.2s
\\
Searching the standard log files (\Claude VSCode.log\, \renderer.log\, \exthost.log\) for \unhandled\ or \object Object\ returns zero matches — the toast text is rendered only in the webview and is not captured in the extension's host logs. This makes self-diagnosis hard for affected users.
Other recurring errors in the same session that may share the same UI default-case path:
\\\\
[ERROR] MCP server \"claude-vscode\" Failed to fetch tools: MCP error -32601: Method not found
[ERROR] MCP server \"claude.ai Netlify\" Connection failed: Cloudflare 502 Bad gateway
[ERROR] MCP server \"claude.ai Goodnotes\" Anthropic Proxy: Invalid content from server
\\
Suggested fix
In the webview's error-handling switch, replace the default branch:
\\\tsUnhandled case: \${error}\
default:
showToast(\); // implicit String(error) → \"[object Object]\"\
\\
with something like:
\\\tsStream interrupted: \${message}\
default:
console.error('Unhandled error case', error);
const message = error?.message ?? error?.error?.message ?? 'Unknown error';
showToast(\, { action: 'Retry' });\
\\
That's a few-line change and immediately makes the failure mode actionable.
Impact
- Blocks user-visible stream rendering on every stall
- Users perceive the assistant as unresponsive even though the SDK is recoverable
- The toast text gives zero diagnostic information; \"View output logs\" opens a log channel that doesn't contain the toast text either
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗