feat(bun): keep server spans open until streaming responses finish - #25025
Open
minwookshin wants to merge 1 commit into
Open
minwookshin wants to merge 1 commit into
minwookshin wants to merge 1 commit into
Conversation
Co-Authored-By: GPT-6 <codex@openai.com>
minwookshin
marked this pull request as ready for review
October 5, 2026 02:25
minwookshin
requested review from
andreiborza and
mydea
and removed request for
a team
October 5, 2026 02:25
| headers: response.headers, | ||
| }); | ||
| // pipeTo settles on completion, source errors, and downstream cancellation. | ||
| void response.body.pipeTo(writable).then(endSpan, endSpan); |
Contributor
There was a problem hiding this comment.
Bug: Errors in streaming responses are silently discarded instead of being captured by Sentry, causing failed requests to be reported as successful.
Severity: HIGH
Suggested Fix
The rejection handler for the pipeTo promise should be modified to correctly handle the error. It should set the span status to an error state (e.g., 'internal_error') and capture the exception with Sentry before ending the span. This will ensure that failures during streaming are properly tracked.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: packages/bun/src/integrations/bunserver.ts#L332
Potential issue: The error handling for streaming responses is incorrect. The code at
`packages/bun/src/integrations/bunserver.ts:332` uses `void
response.body.pipeTo(writable).then(endSpan, endSpan);`. When the stream encounters an
error (e.g., client disconnection, network failure), the promise returned by `pipeTo`
rejects. The rejection handler, `endSpan`, is called, but the error itself is discarded.
This means the Sentry span is not updated to reflect the error status, and the exception
is never captured. Consequently, failed streaming requests are silently reported as
successful, which can mask underlying issues in production.
Also affects:
packages/deno/src/utils/streaming.ts:1~8
Did we get this right? 👍 / 👎 to inform future reviews.
This branch has not been deployed
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.
Bun server spans now remain open until a streaming response completes, errors, or is cancelled. This shares the existing Cloudflare/Deno content-type classifier and preserves backpressure without buffering the response; ordinary responses still finish immediately.
The Bun regression and integration tests pass, including a real server case that fails before this change. Build, lint, formatting, and 41 of 42 package test tasks pass; Deno's existing concurrent-request context test fails both here and after rebuilding the unmodified base sources.
Fixes #23883.