MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / streamResponse

Function streamResponse

packages/deno/src/utils/streaming.ts:50–74  ·  view source on GitHub ↗
(span: Span, res: Response)

Source from the content-addressed store, hash-verified

48 * response to a client.
49 */
50export async function streamResponse(span: Span, res: Response): Promise<Response> {
51 const classification = classifyResponseStreaming(res);
52
53 // not streaming, just end the span and return the response
54 if (!classification.isStreaming || !res.body) {
55 span.end();
56 return res;
57 }
58
59 // Streaming response detected - monitor consumption to keep span alive
60 try {
61 return new Response(
62 monitorStream(res.body, () => span.end()),
63 {
64 status: res.status,
65 statusText: res.statusText,
66 headers: res.headers,
67 },
68 );
69 } catch (_e) {
70 // tee() failed - handle without streaming
71 span.end();
72 return res;
73 }
74}
75
76/**
77 * zero-copy monitoring of stream progress.

Callers 1

wrapDenoRequestHandlerFunction · 0.90

Calls 3

monitorStreamFunction · 0.85
endMethod · 0.65

Tested by

no test coverage detected