Skip to content

Commit 62a1b2c

Browse files
committed
remove timeout
1 parent ae8e345 commit 62a1b2c

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

packages/cloudflare/src/request.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,6 @@ export function wrapRequestHandler(
127127
const streamMonitor = (async () => {
128128
const reader = monitorStream.getReader();
129129

130-
// Safety timeout - abort reading and end span after 5s even if stream hasn't finished
131-
const timeout = setTimeout(() => reader.cancel(), 5000);
132-
133130
try {
134131
let done = false;
135132
while (!done) {
@@ -139,16 +136,13 @@ export function wrapRequestHandler(
139136
} catch {
140137
// Stream error or cancellation - will end span in finally
141138
} finally {
142-
clearTimeout(timeout);
143139
reader.releaseLock();
144140
span.end();
145141
waitUntil?.(flush(2000));
146142
}
147143
})();
148144

149-
if (waitUntil) {
150-
waitUntil(streamMonitor);
151-
}
145+
waitUntil?.(streamMonitor);
152146

153147
// Return response with client stream
154148
return new Response(clientStream, {

packages/cloudflare/src/utils/streaming.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ export type StreamingGuess = {
77
* Classifies a Response as streaming or non-streaming.
88
*
99
* Uses multiple heuristics:
10+
* - No body → not streaming
1011
* - Content-Type: text/event-stream → streaming
1112
* - Content-Length header present → not streaming
12-
* - Otherwise: probes stream with timeout to detect behavior
13+
* - Otherwise: attempts immediate read to detect behavior
14+
* - Stream empty (done) → not streaming
15+
* - Got data without Content-Length → streaming
16+
* - Got data with Content-Length → not streaming
1317
*
1418
* Note: Probing will tee() the stream and return a new Response object.
1519
*

0 commit comments

Comments
 (0)