{"record":{"id":"e3e6b946a312fa73","repo":"sveltejs/kit","slug":"expected-query-live-response-body-to-be-a-readable","errorCode":null,"errorMessage":"Expected query.live response body to be a ReadableStream","messagePattern":"Expected query\\.live response body to be a ReadableStream","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/kit/src/runtime/client/remote-functions/query-live/iterator.js","lineNumber":51,"sourceCode":"\n\tif (!response.ok) {\n\t\t/** @type {RemoteFunctionResponse | undefined} */\n\t\tconst result = await response.json().catch(() => undefined);\n\n\t\tthrow result?.type === 'error'\n\t\t\t? new HandledHttpError(result.error)\n\t\t\t: new HttpError({ status: response.status, message: response.statusText });\n\t}\n\n\tif (response.headers.get('content-type')?.includes('application/json')) {\n\t\t// we can end up here if we e.g. redirect in `handle`\n\t\tconst result = await response.json();\n\t\tawait handle_side_channel_response(result);\n\t\tthrow new HttpError({ status: 500, message: 'Invalid query.live response' });\n\t}\n\n\tif (!response.body) {\n\t\tthrow new Error('Expected query.live response body to be a ReadableStream');\n\t}\n\n\tconst reader = response.body.getReader();\n\n\ttry {\n\t\ton_connect();\n\n\t\tfor await (const node of read_sse(reader)) {\n\t\t\tif (node.type === 'result') {\n\t\t\t\tyield devalue.parse(node.result, app.decoders);\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tawait handle_side_channel_response(node);\n\t\t\tthrow new HttpError({ status: 500, message: 'Invalid query.live response' });\n\t\t}\n\t} finally {\n\t\ttry {","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/runtime/client/remote-functions/query-live/iterator.js#L33-L69","documentation":"After ruling out a JSON body, the client requires response.body to be a ReadableStream to read the live query frames. A null body (e.g. opaque/failed response or an environment without streaming support) makes the client throw this Error.","triggerScenarios":"The fetch for a query.live endpoint returned a response without a body — e.g. a 204/empty response, an opaque cross-origin no-cors response, or a runtime/proxy that strips the body of streaming responses.","commonSituations":"Deploying behind a proxy that buffers/strips streaming bodies; CORS misconfiguration yielding opaque responses; unsupported browser/runtime without ReadableStream on fetch responses; server returning an empty status like 204.","solutions":["Ensure the server endpoint actually streams (SSE/chunked) and returns 200 with a body","Fix CORS so the response is not opaque (proper Access-Control-Allow-Origin, no mode:'no-cors')","Remove/configure proxies that buffer or strip streaming responses","Test in a modern browser/runtime that supports fetch ReadableStream"],"exampleFix":"// before\nconst res = await fetch(url, { mode: 'no-cors' }); // body is null\n// after\nconst res = await fetch(url, { mode: 'cors' }); // streamed body available","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"const hasBody = (res) => res.body instanceof ReadableStream;","tryCatchPattern":"try {\n  await live.query(...);\n} catch (e) {\n  if (e.message === 'Expected query.live response body to be a ReadableStream') {\n    // fall back to polling a regular query\n  } else throw e;\n}","preventionTips":["Verify the runtime supports fetch ReadableStream","Avoid no-cors/opaque requests to streaming endpoints","Configure proxies to pass through chunked/streamed bodies"],"tags":["query-live","streaming","network","readable-stream"],"backgroundTag":"invalid-query-live-response","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}