Conversation
…onse Deno.serve exposes `info.completed`, which settles when the response has been sent or could not be sent. The span now ends on it, so it stays open for streamed responses of every content type, and the SDK returns the handler's response unchanged. Before, the SDK replaced responses it classified as streaming, which moved string bodies off Deno's static fast path and replaced Content-Length with chunked encoding. `completed` is read before the handler runs, because Deno creates it on first access and settles it on the next close of the request, which a WebSocket upgrade does inside the handler. Runtimes without `completed` keep the stream wrapper. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JPeer264
added this pull request to stack #24934
October 1, 2026 11:32
Contributor
size-limit report 📦
|
Member
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 31904c7. Configure here.
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.
Streamed responses on Deno had the same problem as #22876.
Deno.servepassesinfo.completedto the handler, a promise that settles when the response has been sent or could not be sent. Ending thehttp.serverspan on it keeps the span open for streamed responses of every content type, without a content-type classifier, and the SDK can return the handler's response unchanged.Before, the SDK replaced every response that it classified as streaming with a new
Responsearound a JS stream. For a string body, this skips Deno's static fast path and sends the body chunked instead of with aContent-Length. In a local benchmark with a 20 KB HTML string, the replaced response handled about 23% to 32% fewer requests per second. Readingcompletedhad no measurable cost.Details that are not obvious from the diff:
completedis read before the user handler runs. Deno creates the promise on first access and settles it on the next close of the request, and a WebSocket upgrade closes the request inside the handler.completedrejects withInterruptedwhen the response could not be sent (docs: document that ServeHandlerInfo.completed can reject denoland/deno#35747), so the SDK handles the rejection and still ends the span. Deno 2.9.0 resolved it on a client disconnect in my tests.completedwhen it takes the body, not when the client has received it, so these spans end at the same time as before.completedkeep the old stream wrapper. It is in the Deno runtime since 1.46 or earlier, and in the types since 2.0.--unstable-no-legacy-abort, readingcompletedmakes Deno also abortrequest.signalwhen a response fails.🤖 Generated with Claude Code