API Streaming Requests Hang for 3-30 Minutes Before Aborting
Bug Report: API Streaming Requests Hang for 3-30 Minutes Before Aborting
Summary
Claude Code frequently hangs for 3-30 minutes after tool execution completes, before displaying assistant responses. Debug logs show the API streaming request hangs and eventually aborts with "Request was aborted" errors.
Environment
- Claude Code Version: 2.1.17
- OS: Linux (Ubuntu/Debian based)
- Connection: Stable network (DNS: 60ms, API endpoint: 110ms)
- ISP: Home network (tested, not ISP-related)
Detailed Description
After any tool execution (Bash, Read, Git, etc.), the tool result displays immediately but Claude's text response hangs for extended periods (3-30 minutes randomly) before appearing.
Key Findings from Debug Logs:
- Tool execution completes quickly - no issues with tool performance
- API streaming request hangs - no data flowing after request initiated
- Request eventually aborts - Claude Code times out and aborts after ~6 minutes
- Retry succeeds or continues hanging - sometimes multiple retries needed
Evidence from Debug Logs
Hang Example (6 minute gap):
2026-02-01T19:43:03.349Z [DEBUG] Execution timeout: 10000ms
[... 5 minutes 39 seconds of silence ...]
2026-02-01T19:48:42.974Z [ERROR] Error in non-streaming fallback: Request was aborted.
2026-02-01T19:48:42.974Z [ERROR] Error: Error: Request was aborted.
Concurrent Errors (may be related):
2026-02-01T02:17:37.579Z [ERROR] API error (attempt 1/11): 400 400
{"type":"error","error":{"type":"invalid_request_error",
"message":"thinking.enabled.budget_tokens: Input should be greater than or equal to 1024"},
"request_id":"req_011CXgYd9LRPVYMKpf5hsnDA"}
Steps to Reproduce
This occurs randomly but consistently:
- Execute any tool command (git, bash, read, etc.)
- Tool completes and result displays immediately
- Wait for assistant response
- Hang occurs - no response for 3-30 minutes
- Eventually response appears, or user interrupts
Workaround: User interruption often triggers retry that succeeds immediately.
Impact
- Severely impacts productivity - unable to predict when hangs will occur
- Requires constant monitoring - user must watch for hangs and interrupt manually
- No user-side fix available - network tests all pass, issue is API-side
Network Tests (All Pass)
$ time nslookup api.anthropic.com
real 0m0.060s
$ curl -w "\nTime: %{time_total}s\n" -o /dev/null -s https://api.anthropic.com/
Time: 0.109949s
Pattern Analysis
- ✅ Tool execution: Fast (seconds)
- ✅ Network connectivity: Fast (<110ms)
- ✅ DNS resolution: Fast (60ms)
- ❌ API streaming response: Hangs (3-30 minutes)
- ✅ Retry after abort: Often succeeds immediately
Expected Behavior
API streaming responses should start within 1-2 seconds of tool completion, matching the fast network connectivity observed.
Additional Context
Debug logs located at: ~/.claude/debug/<session-id>.txt
The "thinking.enabled.budget_tokens" errors may be triggering a fallback streaming mode that causes these hangs. Errors appear intermittently but correlate with hang frequency.
Request
Please investigate:
- Why API streaming requests hang for minutes despite fast network
- Connection between thinking budget token errors and streaming hangs
- Timeout/retry logic - why 6+ minute wait before abort?
- Whether this is regional/infrastructure related
This issue makes Claude Code nearly unusable for sustained development work. Happy to provide full debug logs or additional testing if needed.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗