You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(cloudflare): Keep http root span alive until streaming responses are consumed (#18087)
Fixes:
https://linear.app/getsentry/issue/JS-1103/spans-are-not-flushed-to-dashboard-when-using-streamtext-with-vercel
The Cloudflare request wrapper was ending the root HTTP span immediately
when the handler returned a streaming Response (e.g.
`result.toTextStreamResponse()`). Since Vercel AI child spans only
finish after the stream is consumed by the client, they were filtered
out by Sentry's `isFullFinishedSpan` check, resulting in transactions
with 0 spans.
--------------
This PR implements a streaming response detection and handles this from
within the http handler:
1. Created `classifyResponseStreaming()` helper
- Detects streaming vs non streaming, via Content-Type (SSE),
Content-Length
2. Updated request wrapper
- Changed from `startSpan()` to `startSpanManual()` for manual span
control
- Monitors streaming response consumption in background
- Ends root span only after stream fully consumed by client
0 commit comments