claude-code - 💡(How to fix) Fix [BUG] Stream idle timeout: server sends zero bytes for 5+ minutes after /v1/messages request accepted (request_id attached) [1 comments, 2 participants]

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…
GitHub stats
anthropics/claude-code#49716Fetched 2026-04-17 08:33:25
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Timeline (top)
labeled ×4commented ×1cross-referenced ×1

Error Message

Claude Code hangs with "API Error: Stream idle timeout - partial response received" (or just spins indefinitely as "Baked for Xm" / "Cogitated for Xm") on some requests. Debug log shows the API request is accepted normally, but then ZERO stream chunks arrive for 5+ minutes — the client hits the 30s "Slow first byte" warning and I have to Ctrl+C. Either the response streams back normally, or the client surfaces a timeout error within ~30–60s if the server hasn't sent a first chunk. The "Slow first byte" warning fires at 30s but the client still waits indefinitely for the stream — it should abort and retry instead.

Error Messages/Logs

2026-04-17T04:08:39.901Z [WARN] Slow first byte: no stream chunk 30.0s after request sent (attempt 1) 2026-04-17T04:13:55.970Z [ERROR] API error (attempt 1/11): undefined Request was aborted. 2026-04-17T04:13:55.975Z [ERROR] API error x-client-request-id=fc5ded9f-2e9e-43e9-9076-c1af834d8b14 (give this to the API team for server-log lookup)

Code Example

Relevant timeline from ~/.claude/debug/<uuid>.txt showing 3 successful requests followed by one pre-stream stall on the same session:

   2026-04-17T04:07:46.542Z [DEBUG] [API REQUEST] /v1/messages x-client-request-id=26622c53-9e00-442d-be11-d05ac57d6b96 source=repl_main_thread
   2026-04-17T04:07:47.376Z [DEBUG] Stream started - received first chunk                    ← 0.8s TTFB   2026-04-17T04:07:48.738Z [DEBUG] Stream started - received first chunk                    ← ✓
   2026-04-17T04:08:04.650Z [DEBUG] [API REQUEST] /v1/messages x-client-request-id=b91f88d4-7039-47b3-b401-41551d2bdcdb source=repl_main_thread
   2026-04-17T04:08:06.001Z [DEBUG] Stream started - received first chunk                    ← 1.4s TTFB   2026-04-17T04:08:08.087Z [DEBUG] [API REQUEST] /v1/messages x-client-request-id=df0cb366-e85a-4859-bc28-3e41f32270e3 source=repl_main_thread
   2026-04-17T04:08:09.474Z [DEBUG] Stream started - received first chunk                    ← 1.4s TTFB   2026-04-17T04:08:09.901Z [DEBUG] [API REQUEST] /v1/messages x-client-request-id=fc5ded9f-2e9e-43e9-9076-c1af834d8b14 source=repl_main_thread
   2026-04-17T04:08:39.901Z [WARN]  Slow first byte: no stream chunk 30.0s after request sent (attempt 1)
   2026-04-17T04:13:55.970Z [ERROR] API error (attempt 1/11): undefined Request was aborted.
   2026-04-17T04:13:55.975Z [ERROR] API error x-client-request-id=fc5ded9f-2e9e-43e9-9076-c1af834d8b14 (give this to the API team for server-log lookup)

   >>> PRIMARY REQUEST FOR SERVER-LOG LOOKUP:
   >>> x-client-request-id = fc5ded9f-2e9e-43e9-9076-c1af834d8b14
   >>> timestamp = 2026-04-17T04:08:09.901Z UTC
   >>> model = claude-opus-4-7, effort = xhigh
   >>> outcome: zero stream chunks in 346 seconds, cancelled manually

   Three immediately preceding requests on the same session succeeded with 0.81.4s TTFB, ruling out network path, auth, proxy, or MTU issues on the client side. Full debug log available on request.
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

Claude Code hangs with "API Error: Stream idle timeout - partial response received" (or just spins indefinitely as "Baked for Xm" / "Cogitated for Xm") on some requests. Debug log shows the API request is accepted normally, but then ZERO stream chunks arrive for 5+ minutes — the client hits the 30s "Slow first byte" warning and I have to Ctrl+C.

This is distinct from the existing reports in that it's NOT a mid-stream stall after partial output — it's a pre-stream stall where the server never sends the first chunk at all. Other requests in the same session (same auth, same socket) return first-chunk in under 2 seconds, so client connectivity is healthy. One specific turn just gets stuck server-side before streaming begins.

Attaching x-client-request-id for server-log lookup.

What Should Happen?

Either the response streams back normally, or the client surfaces a timeout error within ~30–60s if the server hasn't sent a first chunk. The "Slow first byte" warning fires at 30s but the client still waits indefinitely for the stream — it should abort and retry instead.

Error Messages/Logs

Relevant timeline from ~/.claude/debug/<uuid>.txt showing 3 successful requests followed by one pre-stream stall on the same session:

   2026-04-17T04:07:46.542Z [DEBUG] [API REQUEST] /v1/messages x-client-request-id=26622c53-9e00-442d-be11-d05ac57d6b96 source=repl_main_thread
   2026-04-17T04:07:47.376Z [DEBUG] Stream started - received first chunk                    ← 0.8s TTFB ✓
   2026-04-17T04:07:48.738Z [DEBUG] Stream started - received first chunk                    ← ✓
   2026-04-17T04:08:04.650Z [DEBUG] [API REQUEST] /v1/messages x-client-request-id=b91f88d4-7039-47b3-b401-41551d2bdcdb source=repl_main_thread
   2026-04-17T04:08:06.001Z [DEBUG] Stream started - received first chunk                    ← 1.4s TTFB ✓
   2026-04-17T04:08:08.087Z [DEBUG] [API REQUEST] /v1/messages x-client-request-id=df0cb366-e85a-4859-bc28-3e41f32270e3 source=repl_main_thread
   2026-04-17T04:08:09.474Z [DEBUG] Stream started - received first chunk                    ← 1.4s TTFB ✓
   2026-04-17T04:08:09.901Z [DEBUG] [API REQUEST] /v1/messages x-client-request-id=fc5ded9f-2e9e-43e9-9076-c1af834d8b14 source=repl_main_thread
   2026-04-17T04:08:39.901Z [WARN]  Slow first byte: no stream chunk 30.0s after request sent (attempt 1)
   2026-04-17T04:13:55.970Z [ERROR] API error (attempt 1/11): undefined Request was aborted.
   2026-04-17T04:13:55.975Z [ERROR] API error x-client-request-id=fc5ded9f-2e9e-43e9-9076-c1af834d8b14 (give this to the API team for server-log lookup)

   >>> PRIMARY REQUEST FOR SERVER-LOG LOOKUP:
   >>> x-client-request-id = fc5ded9f-2e9e-43e9-9076-c1af834d8b14
   >>> timestamp = 2026-04-17T04:08:09.901Z UTC
   >>> model = claude-opus-4-7, effort = xhigh
   >>> outcome: zero stream chunks in 346 seconds, cancelled manually

   Three immediately preceding requests on the same session succeeded with 0.8–1.4s TTFB, ruling out network path, auth, proxy, or MTU issues on the client side. Full debug log available on request.

Steps to Reproduce

  1. claude --mcp-debug --debug (Opus 4.7, effort=xhigh, native install on Debian)
  2. First prompt: conversational question, responds normally
  3. Second prompt: "sure" (to continue with a simple scaffolding task that requires Read + LS + memory tools)
  4. Turn hangs as "Transfiguring..." / "Baked for Xm" indefinitely
  5. Wait — spinner climbs past 2m, 3m, 4m, 5m with no output
  6. Ctrl+C to cancel (Claude Code does not auto-abort on its own for pre-stream stalls)

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

2.1.112 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

Related open issues that appear to be the same or closely related pattern (all recent):

  • #46987 - stalls between tool calls on macOS
  • #47252 - Ultraplan refinement stalls (WSL)
  • #47555 - large file writes on web
  • #47698 - Ultraplan on darwin
  • #48446 - generic web/macOS

Difference from those: this is a pre-stream stall (no partial output, no mid-stream freeze). The client's watchdog/timeout logic should abort after the 30s "Slow first byte" warning rather than waiting indefinitely for the first chunk.

Suggested client-side fix: treat "Slow first byte > 120s" as fatal for the current attempt and trigger the existing retry path. Server-side: the request_id above should be queryable in your tracing to see why that turn never produced a stream_start event.

extent analysis

TL;DR

Implement a client-side fix to treat "Slow first byte" warnings as fatal after a certain threshold, triggering the existing retry path to handle pre-stream stalls.

Guidance

  • Investigate the server-side logs using the provided x-client-request-id to understand why the stream never started for the specific turn.
  • Implement a client-side fix to abort and retry the request after a certain threshold (e.g., 120s) of "Slow first byte" warnings, rather than waiting indefinitely.
  • Review related open issues (#46987, #47252, #47555, #47698, #48446) to identify potential patterns or common causes for pre-stream stalls.
  • Verify that the fix works by testing the client with the modified retry logic and monitoring the server-side logs for any changes in behavior.

Example

# Pseudo-code example of the proposed client-side fix
if slow_first_byte_warning and elapsed_time > 120s:
    # Trigger existing retry path
    retry_request()

Notes

The provided information suggests that this is a regression, and the issue is specific to the Opus model. The client-side fix should be implemented and tested to handle pre-stream stalls, while the server-side logs should be investigated to understand the root cause of the issue.

Recommendation

Apply the proposed client-side workaround to treat "Slow first byte" warnings as fatal after a certain threshold, triggering the existing retry path. This should help mitigate the issue until a more permanent fix can be implemented.

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…

Still need to ship something?

×6

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

Back to top recommendations

TRENDING