anthropics / anthropics/claude-code

[BUG] Non-streaming retry receives event-stream response (HTTP/2 stream mixup, Intel Mac)

Abierto
#88,110 1 comentario 3 reacciones 0 asignados Ver en GitHub
area:api area:networking bug has repro platform:macos
Lenguaje dominante
Python
Estrellas
145k
Forks
23.1k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

### Preflight Checklist

- [x] I have searched [existing issues](https://github.com/anthropics/claude-code/issues?q=is%3Aissue%20state%3Aopen%20label%3Abug) 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?

**Environment**
- Claude Code: 2.1.236 and 2.1.237
- Node.js: 22.17.0 (nvm, x86_64)
- macOS: 15.7.4 (Intel)
- Cloudflare POP: ICN

**Symptom**
Intermittent, session-sticky. Once triggered, persists until process restart.
Same version on Apple Silicon Mac on same network: no issue.

**Error**
API returned an empty or malformed response (HTTP 200)
- 1st attempt (streaming): 0 stream events, no request-id
- 2nd attempt (non-streaming retry): HTTP 200, content-type event-stream,
64685 bytes — streaming response returned for non-streaming request

**Ruled out**
Proxy, VPN, SSL inspection, firewall, macOS network filter,
MDM, DNS, /etc/hosts, ~/.claude state, auth re-login, reboot,
different network (hotspot), Node.js reinstall, different directory

Image

### What Should Happen?

Streaming requests should receive SSE event streams with a valid
Anthropic request-id. When a streaming request fails and Claude Code
retries as a non-streaming request (stream: false), the retry response
should be a JSON object (content-type: application/json), not an
event-stream. Each HTTP/2 stream should be fully independent — a failed
streaming request's response must never leak into a subsequent
non-streaming retry on the same connection.

### Error Messages/Logs

```shell
API Error: API returned an empty or malformed response (HTTP 200) — check for a proxy or gateway intercepting the request. Response: content-type event-stream, body is an event stream (the non-streaming request was answered with a stream), 2795 bytes, request-id req_011CeDCC5p1UT6L6ifTfnBAU, server cloudflare, intermediary headers anthropic-* cf-cache-status cf-ray. This was the non-streaming retry of streaming request (no Anthropic request-id), which failed with: other; 0 stream events received.
```

### Steps to Reproduce

1. Environment: macOS 15.7.4, Intel x86_64, Node.js 22.17.0 (nvm),
Claude Code 2.1.237
2. Launch `claude` in any directory (no specific project config required)
3. Send any prompt
4. Intermittently, the streaming request fails with 0 SSE events and
no Anthropic request-id
5. Claude Code automatically retries as a non-streaming request
6. The retry receives HTTP 200 with content-type: event-stream
(64685 bytes) instead of expected application/json
7. Error displayed:
"API returned an empty or malformed response (HTTP 200) —
check for a proxy or gateway intercepting the request"
8. Once triggered, every subsequent request in the same session fails
with the same error
9. Restarting the `claude` process temporarily resolves until
the next occurrence

### Claude Model

Opus

### Is this a regression?

Yes, this worked in a previous version

### Last Working Version

_No response_

### Claude Code Version

2.1.237

### Platform

Anthropic API

### Operating System

macOS

### Terminal/Shell

Terminal.app (macOS)

### Additional Information

_No response_

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

No source files or tests are named. Start by reproducing the failure with Claude Code 2.1.237 on Intel macOS using the listed streaming-then-retry sequence, then trace the HTTP/2 request and retry handling. Done means failed streams do not affect later requests and non-streaming retries consistently return JSON rather than event-stream responses.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
macos, node.js
Área
api, networking
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Activo
Claridad
Bastante claro
Aptitud para principiantes
38/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.