cube-js/cube · error
Unsupported response body type for streaming
Error message
Unsupported response body type for streaming
What it means
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'.
Source
Thrown at packages/cubejs-client-core/src/streaming.ts:32
reader.releaseLock?.();
}
return;
}
// Node.js Readable (node-fetch v2 via cross-fetch)
if (body && Symbol.asyncIterator in body) {
for await (const chunk of body as AsyncIterable<Buffer | Uint8Array | string>) {
if (typeof chunk === 'string') {
// Convert string chunks to bytes (rare, but safe)
yield new TextEncoder().encode(chunk);
} else {
yield new Uint8Array(chunk);
}
}
return;
}
throw new Error('Unsupported response body type for streaming');
}
View on GitHub (pinned to 7d981676b3)
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()
Example fix
// before
requestStream: async (m, p) => ({ body: await res.text() })
// after
requestStream: async (m, p) => ({ body: res.body /* ReadableStream */ }) Defensive patterns
Strategy: validation
Validate before calling
const res = await doFetch();
if (!res.body || typeof res.body.getReader !== 'function') {
throw new Error('fetch does not expose a ReadableStream body; use Node 18+ native fetch or a modern browser');
} Type guard
function isStreamableBody(body) {
return body instanceof ReadableStream ||
(body && typeof body.getReader === 'function') ||
body instanceof ArrayBuffer || ArrayBuffer.isView(body);
} Try / catch
try { for await (const c of client.cubeSqlStream(sql)) {} } catch (e) {
if (e.message === 'Unsupported response body type for streaming') {
const res = await client.cubeSql(sql); // non-streaming fallback
} else throw e;
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Invalid response format
- Transport does not support streaming
- options.stream must be a function
- Driver's .streamQuery() method is not implemented yet.
- Unexpected stream end before row with names
AI-assisted analysis of cube-js/cube@7d981676b3 (2026-09-02).
Data as JSON: /api/errors/c78eb772e0dcfda7.
Report an issue: GitHub.