diff --git a/packages/cloudflare/src/utils/streaming.ts b/packages/cloudflare/src/utils/streaming.ts index fee67cbb9f2a..b479edee06a7 100644 --- a/packages/cloudflare/src/utils/streaming.ts +++ b/packages/cloudflare/src/utils/streaming.ts @@ -8,7 +8,6 @@ export type StreamingGuess = { * Heuristics: * - No body → not streaming * - Known streaming Content-Types → streaming (SSE, NDJSON, JSON streaming) - * - text/plain without Content-Length → streaming (some AI APIs) * - Otherwise → not streaming (conservative default, including HTML/SSR) * * We avoid probing the stream to prevent blocking on transform streams (like injectTraceMetaTags) @@ -20,18 +19,15 @@ export function classifyResponseStreaming(res: Response): StreamingGuess { } const contentType = res.headers.get('content-type') ?? ''; - const contentLength = res.headers.get('content-length'); // Streaming: Known streaming content types // - text/event-stream: Server-Sent Events (Vercel AI SDK, real-time APIs) // - application/x-ndjson, application/ndjson: Newline-delimited JSON // - application/stream+json: JSON streaming - // - text/plain (without Content-Length): Some AI APIs use this for streaming text if ( /^text\/event-stream\b/i.test(contentType) || /^application\/(x-)?ndjson\b/i.test(contentType) || - /^application\/stream\+json\b/i.test(contentType) || - (/^text\/plain\b/i.test(contentType) && !contentLength) + /^application\/stream\+json\b/i.test(contentType) ) { return { isStreaming: true }; } diff --git a/packages/deno/src/utils/streaming.ts b/packages/deno/src/utils/streaming.ts index 045a104c5e93..be9a6e4051ed 100644 --- a/packages/deno/src/utils/streaming.ts +++ b/packages/deno/src/utils/streaming.ts @@ -10,7 +10,6 @@ export type StreamingGuess = { * Heuristics: * - No body → not streaming * - Known streaming Content-Types → streaming (SSE, NDJSON, JSON streaming) - * - text/plain without Content-Length → streaming (some AI APIs) * - Otherwise → not streaming (conservative default, including HTML/SSR) * * We avoid probing the stream to prevent blocking on transform streams (like injectTraceMetaTags) @@ -22,18 +21,15 @@ export function classifyResponseStreaming(res: Response): StreamingGuess { } const contentType = res.headers.get('content-type') ?? ''; - const contentLength = res.headers.get('content-length'); // Streaming: Known streaming content types // - text/event-stream: Server-Sent Events (Vercel AI SDK, real-time APIs) // - application/x-ndjson, application/ndjson: Newline-delimited JSON // - application/stream+json: JSON streaming - // - text/plain (without Content-Length): Some AI APIs use this for streaming text if ( /^text\/event-stream\b/i.test(contentType) || /^application\/(x-)?ndjson\b/i.test(contentType) || - /^application\/stream\+json\b/i.test(contentType) || - (/^text\/plain\b/i.test(contentType) && !contentLength) + /^application\/stream\+json\b/i.test(contentType) ) { return { isStreaming: true }; }