anthropics / anthropics/claude-code

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

オープン
#91,003 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
api:anthropic area:core area:desktop bug data-loss platform:windows regression
主要言語
Python
スター
145k
フォーク
23.1k
PR マージ指標
PR 指標を取得中

説明

### 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.

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

評価

技術スタック
bun
領域
api, cli
issue の種類
バグ
難易度
5/5
見積もり時間
1週間以上
活発さ
活発
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。