Skip to content

Content decoder installation after stream close - #6609

Merged
vietj merged 1 commit into
masterfrom
content-decoder-bug
Dec 2, 2026
Merged

vietj merged 1 commit into
masterfrom
content-decoder-bug

Conversation

@vietj

@vietj vietj commented Dec 2, 2026

Copy link
Copy Markdown
Member

Motivation:

On a keep-alive connection the stream closes the instant the response
ends, and closing flipped the guard rejecting a decoder: setting one
asynchronously (pause-then-set) threw "Content has already started"
although the queued content was still deliverable.

Changes:

The decoder lifecycle moves to ContentDecoderHandler (renamed from
SafeContentDecoder), one per stream. The end of the content delivers
handleEnd then handleClose(null); an abrupt close fails the current
and any later decoder with its cause; a clean close keeps the queued
content deliverable. Setting a decoder after delivery still throws.

Assisted-by: Anthropic Claude (claude-fable-5)
Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Signed-off-by: Julien Viet julien@julienviet.com

Motivation:

On a keep-alive connection the stream closes the instant the response
ends, and closing flipped the guard rejecting a decoder: setting one
asynchronously (pause-then-set) threw "Content has already started"
although the queued content was still deliverable.

Changes:

The decoder lifecycle moves to ContentDecoderHandler (renamed from
SafeContentDecoder), one per stream. The end of the content delivers
handleEnd then handleClose(null); an abrupt close fails the current
and any later decoder with its cause; a clean close keeps the queued
content deliverable. Setting a decoder after delivery still throws.

Assisted-by: Anthropic Claude (claude-fable-5)
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Julien Viet <julien@julienviet.com>
@vietj vietj added this to the 5.3.0 milestone Dec 2, 2026
@vietj
vietj merged commit fafdf54 into master Dec 2, 2026
8 checks passed
@vietj
vietj deleted the content-decoder-bug branch December 2, 2026 21:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant