{"record":{"id":"aabfada3cc18651f","repo":"cube-js/cube","slug":"no-response-body-available-for-streaming","errorCode":null,"errorMessage":"No response body available for streaming","messagePattern":"No response body available for streaming","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cubejs-client-core/src/HttpTransport.ts","lineNumber":244,"sourceCode":"      stream: async () => {\n        const response = await fetch(url, {\n          method: requestMethod,\n          headers: {\n            Authorization: this.authorization,\n            'x-request-id': baseRequestId || 'stream-request',\n            ...this.headers,\n          } as HeadersInit,\n          credentials: this.credentials,\n          body: requestMethod === 'POST' ? JSON.stringify(params || {}) : null,\n          signal: actualSignal,\n        });\n\n        if (!response.ok) {\n          throw new Error(`HTTP ${response.status}: ${response.statusText}`);\n        }\n\n        if (!response.body) {\n          throw new Error('No response body available for streaming');\n        }\n\n        return responseChunks(response);\n      },\n      unsubscribe: async () => {\n        if (controller) {\n          controller.abort();\n        }\n      },\n    };\n  }\n}\n\nexport default HttpTransport;\n","sourceCodeStart":226,"sourceCodeEnd":259,"githubUrl":"https://github.com/cube-js/cube/blob/7d981676b36392fec34088b9afab6bdcad40207c/packages/cubejs-client-core/src/HttpTransport.ts#L226-L259","documentation":"After a successful (response.ok) fetch in HttpTransport.requestStream(), the code checks that a readable body exists before streaming chunks via responseChunks(response). If response.body is null/undefined, it throws 'No response body available for streaming'. This happens in environments whose fetch implementation does not expose a streaming ReadableStream body.","triggerScenarios":"Calling requestStream/cubeApi.stream() in a runtime where the Response from fetch has no .body ReadableStream: browsers without the streams API, apps using a fetch polyfill (whatwg-fetch), old Node fetch without streaming, stubbed fetch in tests returning { ok: true } without a body, or responses through service-worker/opaque (no-cors) handling that strip the body.","commonSituations":"Legacy browser targets with polyfilled fetch; React Native where fetch lacks response.body streams; jsdom/happy-dom tests with a stubbed fetch; a service worker intercepting and returning a body-less Response.","solutions":["Run in an environment whose fetch supports ReadableStream bodies (modern browser, or polyfill with web-streams-polyfill / node-fetch v3+).","If the runtime cannot support streaming, use the non-streaming load() method instead of stream().","In tests, make the fetch stub return a real Response with a body (e.g. new Response(JSON.stringify(data))).","Check for a service worker or no-cors request mode stripping the body; adjust the interceptor or use cors mode."],"exampleFix":"// before (unsupported runtime)\nfor await (const row of cubeApi.stream(query)) { ... } // throws 'No response body available for streaming'\n\n// after (fallback to non-streaming load)\ntry {\n  for await (const row of cubeApi.stream(query)) { ... }\n} catch (e) {\n  if (e.message.includes('No response body available')) {\n    const resultSet = await cubeApi.load(query);\n    const rows = resultSet.tablePivot();\n  } else { throw e; }\n}","handlingStrategy":"fallback","validationCode":"// Feature-detect streaming support before using stream()\nconst supportsStreaming = typeof Response !== 'undefined' &&\n  new Response(new ReadableStream()).body instanceof ReadableStream;\nconst fetchRows = supportsStreaming ? () => cubeApi.stream(query) : () => cubeApi.load(query);","typeGuard":"function hasStreamBody(res: Response): res is Response & { body: ReadableStream } {\n  return res.body != null && typeof res.body.getReader === 'function';\n}","tryCatchPattern":"try {\n  for await (const row of cubeApi.stream(query)) { handle(row); }\n} catch (e) {\n  if (e.message.includes('No response body available for streaming')) {\n    const rs = await cubeApi.load(query); // non-streaming fallback\n    handleBatch(rs.tablePivot());\n  } else { throw e; }\n}","preventionTips":["Feature-detect Response.body streaming support once at startup and choose stream() vs load().","Avoid fetch polyfills on streaming code paths; use native fetch on modern browsers only.","In tests, stub fetch with real Response objects: new Response(JSON.stringify(data)).","Audit service workers / interceptors that might strip or replace response bodies.","On React Native or other runtimes without stream bodies, use load() directly."],"tags":["streaming","fetch","runtime-compatibility","response-body"],"backgroundTag":"no-streaming-response-body","analyzedSha":"7d981676b36392fec34088b9afab6bdcad40207c","analyzedAt":"2026-09-02T03:45:10.400Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}