{"record":{"id":"506645d6ff0c4ab5","repo":"apache/answer","slug":"readablestream-not-supported","errorCode":null,"errorMessage":"ReadableStream not supported","messagePattern":"ReadableStream not supported","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ui/src/utils/requestAi.ts","lineNumber":224,"sourceCode":"      method: 'POST',\n      signal: combinedSignal,\n      headers: {\n        Authorization: token,\n        'Accept-Language': lang,\n        'Content-Type': 'application/json',\n        ...options.headers,\n      },\n    });\n\n    // unified error handling (based on request.ts logic)\n    if (!response.ok) {\n      await handleHttpError(response, options);\n      return;\n    }\n\n    const reader = response.body?.getReader();\n    if (!reader) {\n      throw new Error('ReadableStream not supported');\n    }\n\n    // store the current reader so it can be cancelled later\n    requestState.currentReader = reader;\n\n    const decoder = new TextDecoder();\n    let buffer = '';\n\n    const processStream = async (): Promise<void> => {\n      try {\n        const { value, done } = await reader.read();\n\n        if (done) {\n          options.onComplete?.();\n          requestState.isProcessing = false;\n          requestState.currentReader = null;\n          return;\n        }","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/apache/answer/blob/3b9f1370612e690a0b7f230f05e688930db4c6d3/ui/src/utils/requestAi.ts#L206-L242","documentation":"requestAi throws this when the browser's fetch Response body is not a ReadableStream, i.e. response.body?.getReader() returns undefined. The AI streaming feature depends on the Streams API to consume the response incrementally.","triggerScenarios":"Calling requestAi (streaming mode) in an environment where Response.body is null or lacks getReader(): old browsers without ReadableStream support, non-HTTPS contexts in some browsers, or certain polyfilled/undici-like fetch implementations that return null bodies.","commonSituations":"Running the app in legacy browsers (older Safari/IE-based webviews), embedding the UI in an old WebView, using a fetch polyfill that strips the body stream, or service-worker/proxy layers that buffer the response so body.getReader is unavailable.","solutions":["Upgrade to a browser that supports ReadableStream (all modern evergreen browsers, Safari 10.1+).","Check that fetch is native, not polyfilled; remove or upgrade the fetch polyfill for this call path.","Serve the app over HTTPS/modern context if targeting browsers that gate streams on secure contexts.","Add an explicit feature check before calling requestAi and fall back to a non-streaming request path."],"exampleFix":"// before\nconst reader = response.body?.getReader();\nif (!reader) {\n  throw new Error('ReadableStream not supported');\n}\n// after\nif (typeof response.body?.getReader !== 'function') {\n  const text = await response.text(); // non-streaming fallback\n  return handleFullText(text);\n}\nconst reader = response.body.getReader();","handlingStrategy":"type-guard","validationCode":"const supportsStreams = typeof Response !== 'undefined' && new Response().body?.getReader instanceof Function;","typeGuard":"function hasReadableStream(res: Response): res is Response & { body: ReadableStream } {\n  return !!res.body && typeof res.body.getReader === 'function';\n}","tryCatchPattern":"try {\n  await requestAi(params);\n} catch (e) {\n  if (e instanceof Error && e.message === 'ReadableStream not supported') {\n    await requestAiNonStreaming(params); // fallback path\n  } else throw e;\n}","preventionTips":["Feature-check ReadableStream once at app startup and disable streaming UI when unsupported","Avoid fetch polyfills that don't expose Response.body","Test in target browsers/webviews before shipping streaming features","Serve over HTTPS where secure-context gating applies"],"tags":["browser-compatibility","streams","fetch"],"backgroundTag":"readablestream-not-supported","analyzedSha":"3b9f1370612e690a0b7f230f05e688930db4c6d3","analyzedAt":"2026-09-05T18:18:39.533Z","contentChangedAt":"2026-09-05T18:18:39.533Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}