anthropics / anthropics/claude-code
[BUG] "JSON Parse error: Unexpected EOF" discards turns mid-stream — regression between 2.1.146 and 2.1.149
- Ngôn ngữ chính
- Python
- Star
- 145k
- Fork
- 23.1k
- Chỉ số merge pull request
- Chỉ số pull request đang chờ
Mô tả
### 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.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- bun
- Lĩnh vực
- api, cli
- Loại issue
- Lỗi
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Sôi nổi
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 25/100