Skip to content

bun, deno: http.server span ends before a streamed SSR response has been sent #25537

Open

Description

@JPeer264

bunServerIntegration and denoServeIntegration end the http.server span when the handler returns, unless the shared classifier classifyResponseStreaming (@sentry/core/server) says that the response streams. The classifier knows Server-Sent Events, NDJSON, application/stream+json, and text/plain and text/x-component without a Content-Length. HTML does not count as streamed, because a buffered new Response(html) has no Content-Length either.

So for a streamed SSR page, the span ends too early. Spans created while the body streams, for example a Suspense render or a data fetch, end after their root span. On Cloudflare, #24932 adds the isStreamingResponse option for this. Bun and Deno have no fix yet.

Proposal

Deno: end the span on info.completed (Deno.ServeHandlerInfo) for every response, and return the handler's response unchanged. completed settles when the response has been sent or could not be sent. Then Deno needs no classifier and no option, and static bodies keep Deno's fast path and their Content-Length.

Bun: Bun.serve does not tell the handler when the response has been sent. Add isStreamingResponse(response, request) to bunServerIntegration, with the same contract as on Cloudflare: true keeps the span open until the body has been sent, false ends it at handler return, and any other value uses classifyResponseStreaming.

Sentry.init({
  dsn: process.env.SENTRY_DSN,
  integrations: [
    Sentry.bunServerIntegration({
      isStreamingResponse: response =>
        response.headers.get('content-type')?.startsWith('text/html') ? true : undefined,
    }),
  ],
});

Activity

  1. linear-code commented on Oct 19, 2026

    @linear-code
  2. logaretm commented on Oct 20, 2026

    @logaretm
    Member

    @JPeer264 saw you have a PR for deno here, are you doing bun too?

  3. JPeer264 commented on Oct 20, 2026

    @JPeer264
    MemberAuthor

    The opened PR for Deno is far away from being done. But yes it is planned to do both.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions