anthropics / anthropics/claude-code

[BUG] "JSON Parse error: Unexpected EOF" discards turns mid-stream — regression between 2.1.146 and 2.1.149

Abierto
#91,003 1 comentario 0 reacciones 0 asignados Ver en GitHub
api:anthropic area:core area:desktop bug data-loss platform:windows regression
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?

Turns fail with `API Error: JSON Parse error: Unexpected EOF`. The request reaches the
API and starts streaming — a real requestId is assigned and partial content is written
to the transcript — then the turn dies and all of its work is discarded.

No 4xx/5xx is ever logged, so this is not a server-side failure. The error string is
JavaScriptCore phrasing (Node/V8 would say "Unexpected end of JSON input"), so the
failing JSON.parse is inside the Bun-built CLI binary — consistent with a truncated or
malformed SSE data: line.

127 unique occurrences (deduplicated by requestId) across 53 distinct days,
2026-06-01 to 2026-08-31. Currently ~12/day. Losses per event range from a few seconds
to 1186s — about 20 minutes of work gone in a single failure.

### What Should Happen?

A malformed SSE frame should be retried, or at minimum surfaced as a recoverable error
that preserves the turn — rather than discarding up to 20 minutes of completed work.

### Error Messages/Logs

```shell
%LOCALAPPDATA%\Claude\Logs\main.log

[warn] [CCD CycleHealth] local_ api_error (success): API Error: JSON Parse error: Unexpected EOF
[info] [CCD CycleHealth] unhealthy cycle for local_ (1186s, hadFirstResponse=true, reason=api_error)

Note hadFirstResponse=true — streaming had already begun.

Transcript record: "error":"unknown", "isApiErrorMessage":true, a valid requestId,
"model":"".

Observed wasted cycle durations:
0s, 27s, 62s, 78s, 122s, 241s, 289s, 704s, 834s, 961s, 1131s, 1186s
```

### Steps to Reproduce

Not deterministically reproducible. It surfaces on its own during normal use, typically
several minutes into a turn.

Conditions where it appears here:
1. Windows 11, Claude Desktop, 4-7 concurrent CLI sessions on the machine.
2. Work normally for a few minutes.
3. The turn dies with the error above; frequency is currently ~12/day.

It is NOT correlated with context size: failures occur at 81K and at 803K input tokens
alike, while 97.4% of 14,300 successful turns fall in that same range.

### Claude Model

Opus

### Is this a regression?

Yes, this worked in a previous version

### Last Working Version

2.1.146

### Claude Code Version

2.1.247

### Platform

Anthropic API

### Operating System

Windows

### Terminal/Shell

Other

### Additional Information

Platform note: Claude subscription (not a pay-as-you-go API key), routed through
api.anthropic.com. Not Bedrock, not Vertex.

Environment note: run from the Claude Desktop app on Windows (entrypoint
"claude-desktop"), not from a terminal emulator — hence "Other" above.

Guía de contribución

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

Línea de trabajo

Start with %LOCALAPPDATA%\Claude\Logs\main.log and the CCD CycleHealth entries, then compare behavior between versions 2.1.146, 2.1.149, and 2.1.247 around malformed SSE data frames. Done means a mid-stream parse failure is retried or reported as recoverable while preserving the partial turn and its completed work.

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

Evaluación

Stack tecnológico
bun
Área
api, cli
Tipo de issue
Error
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Activo
Claridad
Necesita aclaración
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.