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

未關閉
#25,537 3 則留言 0 個 reaction 已指派 1 人 在 GitHub 檢視

維護者通常 1 天內回覆

@JPeer264 已經在處理了。

開始於 2026年10月20日。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
45/100
Issue 類型
功能
描述清晰度
基本清楚
活躍度
活躍
技術堆疊
bun, deno, typescript

研究方向

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.

由索引模型根據 Issue 內容生成。

描述

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,
    }),
  ],
});
主要語言
TypeScript
星號
8.8k
分支
1.9k
平均合併
1 天 8 小時
30 天內合併 PR
744

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

getsentry/sentry-javascript 的其他 Issue

查看 getsentry/sentry-javascript 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。