Repository navigation
fix(server-utils): Mark AI streaming spans as errored when the stream fails midway - #26023
Merged
Merged
Conversation
… fails midway When a streamed OpenAI, Anthropic or Google GenAI response threw partway through, the gen_ai span still ended ok, because the stream wrappers had try/finally with no catch. They now set internal_error, or cancelled for an AbortError. A consumer that stops reading keeps the span ok. Fixes #25994 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
size-limit report 📦Compared: b257c95 (PR test merge using develop at a2dbec0) Against: a2dbec0 (develop) · base run #65070 ✅ Baseline matches: this diff contains only this PR's changes.
|
Contributor
Optional E2E testsSome optional checks were not successful. They do not block the merge. 6 not successful, 50 successful. See the run.
Successful checks
|
Collaborator
Author
|
bugbot run |
…usage on Anthropic stream errors A Google timeout also throws AbortError, and `cancelled` is sent as `ok` under span streaming, so matching on the error name made timeouts look like success. Google now records `cancelled` only when the caller's abortSignal fired. OpenAI and Anthropic swallow aborts in their SDKs, so they just set internal_error. messages.stream() errors now go through endStreamSpan, so they keep partial usage like the create path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit a9d1413. Configure here.
RulaKhaled
marked this pull request as ready for review
November 5, 2026 12:55
RulaKhaled
requested review from
andreiborza and
mydea
and removed request for
a team
November 5, 2026 12:55
43081j
pushed a commit
to 43081j/sentry-javascript
that referenced
this pull request
Nov 9, 2026
… fails midway (getsentry#26023) When a streamed OpenAI, Anthropic or Google GenAI response threw partway through, for example on a dropped connection, the `gen_ai` span still ended `ok`. The stream wrappers had `try/finally` with no `catch`. They now set `internal_error`, as Workers AI does. Google sets `cancelled` when the caller's `abortSignal` fired, while its timeouts stay errors. `messages.stream()` failures now keep partial usage too. A consumer that stops with `break` keeps the span `ok`. One that throws into the generator, which `Readable.from` does when a piped client disconnects, records `internal_error`. Fixes getsentry#25994 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
RulaKhaled
added a commit
that referenced
this pull request
Nov 10, 2026
An aborted thread or tool-runner stream ended its chat span ok with nothing to show it was cut short. Mark it cancelled, as Google GenAI does since #26023, both mid-stream and before the response arrives. Also pin the error span of an attempt the thread recovered from, which is deliberate. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
51 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a streamed OpenAI, Anthropic or Google GenAI response threw partway through, for example on a dropped connection, the
gen_aispan still endedok. The stream wrappers hadtry/finallywith nocatch.They now set
internal_error, as Workers AI does. Google setscancelledwhen the caller'sabortSignalfired, while its timeouts stay errors.messages.stream()failures now keep partial usage too.A consumer that stops with
breakkeeps the spanok. One that throws into the generator, whichReadable.fromdoes when a piped client disconnects, recordsinternal_error.Fixes #25994
🤖 Generated with Claude Code