{"record":{"id":"c78eb772e0dcfda7","repo":"cube-js/cube","slug":"unsupported-response-body-type-for-streaming","errorCode":null,"errorMessage":"Unsupported response body type for streaming","messagePattern":"Unsupported response body type for streaming","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cubejs-client-core/src/streaming.ts","lineNumber":32,"sourceCode":"      reader.releaseLock?.();\n    }\n    return;\n  }\n\n  // Node.js Readable (node-fetch v2 via cross-fetch)\n  if (body && Symbol.asyncIterator in body) {\n    for await (const chunk of body as AsyncIterable<Buffer | Uint8Array | string>) {\n      if (typeof chunk === 'string') {\n        // Convert string chunks to bytes (rare, but safe)\n        yield new TextEncoder().encode(chunk);\n      } else {\n        yield new Uint8Array(chunk);\n      }\n    }\n    return;\n  }\n\n  throw new Error('Unsupported response body type for streaming');\n}\n","sourceCodeStart":14,"sourceCodeEnd":34,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-client-core/src/streaming.ts#L14-L34","documentation":"responseChunks() in streaming.ts can stream ReadableStream, AsyncIterable, and ArrayBuffer/TypedArray bodies. If the transport's underlying response body is any other type (e.g. a string or undefined), it throws 'Unsupported response body type for streaming'.","triggerScenarios":"requestStream() receiving a response whose body is a plain string, Blob-like object, or undefined — typically from a custom transport or a mocked/polyfilled fetch without a ReadableStream body.","commonSituations":"Test environments (jsdom/node-fetch versions) where response.body isn't a ReadableStream; custom transports resolving with text instead of a stream; fetch polyfills lacking streaming body support.","solutions":["Use a fetch implementation returning a ReadableStream body (native fetch in Node 18+ or browsers)","Fix custom transports to resolve with the raw Response object, not parsed text","Remove or upgrade fetch polyfills that don't support streaming bodies","If streaming is unsupported in your environment, fall back to non-streaming cubeSql()"],"exampleFix":"// before\nrequestStream: async (m, p) => ({ body: await res.text() })\n// after\nrequestStream: async (m, p) => ({ body: res.body /* ReadableStream */ })","handlingStrategy":"validation","validationCode":"const res = await doFetch();\nif (!res.body || typeof res.body.getReader !== 'function') {\n  throw new Error('fetch does not expose a ReadableStream body; use Node 18+ native fetch or a modern browser');\n}","typeGuard":"function isStreamableBody(body) {\n  return body instanceof ReadableStream ||\n    (body && typeof body.getReader === 'function') ||\n    body instanceof ArrayBuffer || ArrayBuffer.isView(body);\n}","tryCatchPattern":"try { for await (const c of client.cubeSqlStream(sql)) {} } catch (e) {\n  if (e.message === 'Unsupported response body type for streaming') {\n    const res = await client.cubeSql(sql); // non-streaming fallback\n  } else throw e;\n}","preventionTips":["Use runtimes with native fetch streaming (Node 18+, modern browsers)","Do not parse response to text inside custom requestStream transports","Avoid fetch polyfills without ReadableStream body support"],"tags":["streaming","transport","response-format"],"backgroundTag":"unsupported-response-body","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}