claude-code - 💡(How to fix) Fix Unhandled case: [object Object] shown when SDK stream ends with had_error after API stall — breaks conversation continuity

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

When the Anthropic API SSE stream stalls mid-tool-call, the next bash tool dispatch aborts with a generic "Shell command failed" error and the stream ends with had_error=true / no result. The VSCode UI fails to render this state gracefully and shows Unhandled case: [object Object] in the chat. The conversation cannot be resumed normally — on reload, the in-progress turn is lost.

Error Message

When the Anthropic API SSE stream stalls mid-tool-call, the next bash tool dispatch aborts with a generic "Shell command failed" error and the stream ends with had_error=true / no result. The VSCode UI fails to render this state gracefully and shows Unhandled case: [object Object] in the chat. The conversation cannot be resumed normally — on reload, the in-progress turn is lost.

  1. Render a friendly error in chat (e.g. "Connection interrupted — tap to retry") instead of the raw Unhandled case: [object Object] string. 10:06:58.759 [WARN] [Stall] tool_dispatch_end tool=Bash outcome=error durationMs=24 10:06:58.759 [DEBUG] Bash tool error (24ms): Shell command failed 10:12:43.017 [WARN] Streaming stall detected: 43.5s gap between events (stall #1) 10:12:46.045 [WARN] [Stall] tool_dispatch_end tool=Bash outcome=error durationMs=27 10:12:46.045 [DEBUG] Bash tool error (27ms): Shell command failed Repro pattern observed: a 5-call parallel Bash batch where the first call sits in the permission UI for ~30s, then calls 2–5 fire back-to-back within ~70ms. The 3rd shell spawn fails with a sub-100ms error. Also reproduces on a single bash call whose output is large (~333KB image extraction via `magick`) — looks like API SSE backpressure or response size correlates. The UI's `Unhandled case: [object Object]` is a dead end: no retry button, no error context, and reloading the panel loses the in-flight turn entirely. For long planning / coding sessions this is severe — a 90-minute session can be lost to one stall.
  2. Catch the unhandled error in the chat renderer and show a friendly message + retry affordance.
  3. Persist the in-flight turn before reload so resume works after a stream error.

Root Cause

When the Anthropic API SSE stream stalls mid-tool-call, the next bash tool dispatch aborts with a generic "Shell command failed" error and the stream ends with had_error=true / no result. The VSCode UI fails to render this state gracefully and shows Unhandled case: [object Object] in the chat. The conversation cannot be resumed normally — on reload, the in-progress turn is lost.

Fix Action

Fix / Workaround

When the Anthropic API SSE stream stalls mid-tool-call, the next bash tool dispatch aborts with a generic "Shell command failed" error and the stream ends with had_error=true / no result. The VSCode UI fails to render this state gracefully and shows Unhandled case: [object Object] in the chat. The conversation cannot be resumed normally — on reload, the in-progress turn is lost.

``` 10:06:58.759 [WARN] [Stall] tool_dispatch_end tool=Bash outcome=error durationMs=24 10:06:58.759 [DEBUG] Bash tool error (24ms): Shell command failed 10:08:26.531 sdk_stream_ended_no_result {"had_error":true, "message_count":177} ```

``` 10:12:43.017 [WARN] Streaming stall detected: 43.5s gap between events (stall #1) 10:12:46.045 [WARN] [Stall] tool_dispatch_end tool=Bash outcome=error durationMs=27 10:12:46.045 [DEBUG] Bash tool error (27ms): Shell command failed 10:12:29.490 sdk_stream_ended_no_result {"had_error":true, "message_count":199} ```

RAW_BUFFERClick to expand / collapse

Summary

When the Anthropic API SSE stream stalls mid-tool-call, the next bash tool dispatch aborts with a generic "Shell command failed" error and the stream ends with had_error=true / no result. The VSCode UI fails to render this state gracefully and shows Unhandled case: [object Object] in the chat. The conversation cannot be resumed normally — on reload, the in-progress turn is lost.

Environment

  • Claude Code extension: cc_version=2.1.141.149 (cc_entrypoint=claude-vscode)
  • VSCode: 1.120.0 (commit 0958016b2af9f09bb4257e0df4a95e2f90590f9f)
  • macOS Darwin 25.4.0
  • Model: Opus 4.7 (1M context)

Expected behavior

When the SDK stream errors out, the UI should:

  1. Render a friendly error in chat (e.g. "Connection interrupted — tap to retry") instead of the raw Unhandled case: [object Object] string.
  2. Preserve the conversation so reloading the panel doesn't lose the prior turn.

Actual behavior

Sequence from the extension log (relevant excerpts):

``` 10:06:58.759 [WARN] [Stall] tool_dispatch_end tool=Bash outcome=error durationMs=24 10:06:58.759 [DEBUG] Bash tool error (24ms): Shell command failed 10:08:26.531 sdk_stream_ended_no_result {"had_error":true, "message_count":177} ```

``` 10:12:43.017 [WARN] Streaming stall detected: 43.5s gap between events (stall #1) 10:12:46.045 [WARN] [Stall] tool_dispatch_end tool=Bash outcome=error durationMs=27 10:12:46.045 [DEBUG] Bash tool error (27ms): Shell command failed 10:12:29.490 sdk_stream_ended_no_result {"had_error":true, "message_count":199} ```

Repro pattern observed: a 5-call parallel Bash batch where the first call sits in the permission UI for ~30s, then calls 2–5 fire back-to-back within ~70ms. The 3rd shell spawn fails with a sub-100ms error. Also reproduces on a single bash call whose output is large (~333KB image extraction via `magick`) — looks like API SSE backpressure or response size correlates.

Impact

The UI's `Unhandled case: [object Object]` is a dead end: no retry button, no error context, and reloading the panel loses the in-flight turn entirely. For long planning / coding sessions this is severe — a 90-minute session can be lost to one stall.

Suggested fixes (priority order)

  1. Catch the unhandled error in the chat renderer and show a friendly message + retry affordance.
  2. Persist the in-flight turn before reload so resume works after a stream error.
  3. Investigate the underlying stream stall — large tool outputs or parallel bash batches seem to correlate.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

FAQ

Expected behavior

When the SDK stream errors out, the UI should:

  1. Render a friendly error in chat (e.g. "Connection interrupted — tap to retry") instead of the raw Unhandled case: [object Object] string.
  2. Preserve the conversation so reloading the panel doesn't lose the prior turn.

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Unhandled case: [object Object] shown when SDK stream ends with had_error after API stall — breaks conversation continuity