[BUG] Webview: Monaco editor worker loading fails, triggers "Unhandled case" banner and interrupts session
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 Claude Code VS Code extension intermittently shows an "Unhandled case: [object Object]" banner in the chat UI and interrupts the active Claude session mid-stream.
The root cause appears to be the Monaco editor (used for code rendering in chat) failing to load its web workers in the webview's CSP/sandbox context. The resulting TypeError loops hundreds of times until the React error boundary catches it and renders the opaque [object Object] banner, killing the in-flight stream.
This is distinct from #59024 (which was about AskUserQuestion / permission stream — those errors don't appear in my Node-side log; this is purely a webview render-loop failure).
What Should Happen?
Monaco's worker setup should define MonacoEnvironment.getWorker for the webview's restricted CSP environment so workers can load without crashing. Failing that, the React error boundary should render a non-opaque error and the active Claude session should not be terminated by webview render failures.
Error Messages/Logs
=== Webview DevTools console (Cmd+Shift+P → "Developer: Open Webview Developer Tools") ===
Preceded by 6× Content Security Policy violations on font-src:
Loading the font '<URL>' violates the following Content Security Policy directive: "font-src 'self' <URL>". The action has been blocked.
Then Monaco initialization fails:
Could not create web worker(s). Falling back to loading web worker code in main thread, which might cause UI freezes.
You must define a function MonacoEnvironment.getWorkerUrl or MonacoEnvironment.getWorker
Then hundreds of identical uncaught errors in a loop:
Uncaught Error: Cannot read properties of undefined (reading 'toUrl')
TypeError: Cannot read properties of undefined (reading 'toUrl')
at Cv.toUri (index.js:22:12569)
at Cv.asBrowserUri (index.js:22:12022)
at index.js:36:30407
at new Promise (<anonymous>)
at $M.$loadForeignModule (index.js:36:30269)
at index.js:631:7606
at async index.js:1419:6748
at Cv.toUri (index.js:22:12569)
at Cv.asBrowserUri (index.js:22:12022)
at index.js:36:30407
at new Promise (<anonymous>)
at $M.$loadForeignModule (index.js:36:30269)
at index.js:631:7606
at async index.js:1419:6748
at index.js:14:18
After ~100+ iterations, the React error boundary fires and renders "Unhandled case: [object Object]" in the chat UI. The active Claude stream is interrupted at this point and cannot be resumed without a webview reload.
=== Output channel (Anthropic.claude-code.Claude VSCode.log) ===
The Node side is clean — no errors that correlate with the banner. Only the harmless routine line per prompt:
[ERROR] MCP server "claude-vscode" Failed to fetch tools: MCP error -32601: Method not found
No AskUserQuestion errors, no JSON parse errors, no permission stream errors. The Node-side has no idea anything is wrong.
Steps to Reproduce
- Open VS Code with the Claude Code extension v2.1.141 on macOS (Darwin 25.4.0)
- Open the Claude Code sidebar and start a session in any reasonably active repo
- Run typical agentic tasks (file edits, bash commands, multi-step work)
- Within minutes to hours (intermittent — no deterministic trigger found), the "Unhandled case: [object Object]" banner appears and the in-flight stream is killed
- Open Webview DevTools (Cmd+Shift+P → "Developer: Open Webview Developer Tools") and the Console will show the Monaco worker loading stacktrace above, looping continuously
Workaround: Reload the webview (Cmd+Shift+P → "Developer: Reload Webviews") to clear the banner and continue.
The bug is reproducible 100% across sessions on my system — it's only a question of when it triggers, not if.
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.141 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
VS Code integrated terminal
Additional Information
Environment:
- macOS Darwin 25.4.0 (Apple Silicon)
- VS Code latest
- Claude Code extension 2.1.141 (native ARM64 binary)
- Multiple MCP servers configured (.mcp.json with Supabase HTTP), no issues with MCP-side connections
Related: I left a comment on #59024 with the same stacktrace before realising the original report was about a different root cause (AskUserQuestion permission stream). Filing this as a separate issue per the duplicate-detection bot's recommendation, since this one is purely Monaco-side and the symptom collision at the React error boundary is misleading.
Happy to provide additional webview console dumps, profile traces, or test a fix.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗