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

Aberta
#25,537 3 comentários 0 reações 1 responsável Ver no GitHub

Mantenedores costumam responder em até 1 dia

@JPeer264 já está trabalhando nisso.

Desde 20/10/2026.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
45/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
bun, deno, typescript

Direção de pesquisa

Start by reading bunServerIntegration, denoServeIntegration, and the shared classifyResponseStreaming in @sentry/core/server; compare the Cloudflare implementation referenced in the issue. Check the Bun and Deno integration tests for span lifetime and response behavior. Done means streamed SSR spans stay open through sending, while Deno returns the handler response unchanged and Bun supports the proposed callback fallback.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

Bun Feature Spans

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, getsentry/sentry-javascript#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,
    }),
  ],
});
Linguagem predominante
TypeScript
Estrelas
8.8k
Forks
1.9k
Merge médio
1d 8h
PRs com merge (30d)
744

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de getsentry/sentry-javascript

Todas as issues de getsentry/sentry-javascript

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.