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

Đang mở
#25,537 3 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@JPeer264 đang làm issue này rồi.

Từ ngày 20/10/2026.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
45/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
bun, deno, typescript
Lĩnh vực
backend, observability

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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,
    }),
  ],
});
Ngôn ngữ chính
TypeScript
Star
8.8k
Fork
1.9k
Merge trung bình
1 ngày 8 giờ
Pull request đã merge (30 ngày)
744

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của getsentry/sentry-javascript

Tất cả issue của getsentry/sentry-javascript

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.