datawhalechina/hello-agents · error
浏览器不支持流式响应,无法获取研究进度
Error message
浏览器不支持流式响应,无法获取研究进度
What it means
Thrown by the helloagents-deepresearch frontend when the /research/stream response succeeded (resp.ok) but response.body is undefined — i.e. this browser/runtime cannot expose the response as a ReadableStream. Since the whole deep-research UX depends on incrementally reading SSE frames, the code refuses to continue rather than hang on a request() that never yields chunks.
Source
Thrown at code/chapter14/helloagents-deepresearch/frontend/src/services/api.ts:42
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "text/event-stream"
},
body: JSON.stringify(payload),
signal: options.signal
});
if (!response.ok) {
const errorText = await response.text().catch(() => "");
throw new Error(
errorText || `研究请求失败,状态码:${response.status}`
);
}
const body = response.body;
if (!body) {
throw new Error("浏览器不支持流式响应,无法获取研究进度");
}
const reader = body.getReader();
const decoder = new TextDecoder("utf-8");
let buffer = "";
while (true) {
const { value, done } = await reader.read();
buffer += decoder.decode(value || new Uint8Array(), { stream: !done });
let boundary = buffer.indexOf("\n\n");
while (boundary !== -1) {
const rawEvent = buffer.slice(0, boundary).trim();
buffer = buffer.slice(boundary + 2);
if (rawEvent.startsWith("data:")) {
const dataPayload = rawEvent.slice(5).trim();
if (dataPayload) {View on GitHub (pinned to 606a07d341)
Solutions
- Confirm the runtime: log `'body' in Response.prototype` or typeof resp.body — if undefined, the environment lacks streaming fetch.
- Upgrade/switch to a modern browser (Chrome 76+, Firefox 69+, Safari 14.1+ for mature ReadableStream responses).
- If a legacy runtime must be supported, implement a non-streaming fallback endpoint (POST /research and poll or wait for the full JSON result).
- In tests, polyfill ReadableStream (e.g. web-streams-polyfill) or mock fetch with a body-providing stub.
Defensive patterns
Strategy: type-guard
Validate before calling
export function supportsStreamingResponses(): boolean {
return typeof ReadableStream !== 'undefined'
&& typeof Response !== 'undefined'
&& 'body' in Response.prototype;
}
if (!supportsStreamingResponses()) {
useNonStreamingFallback(); // POST /research once, render final result
} Type guard
function hasReadableBody(resp: Response): resp is Response & { body: ReadableStream<Uint8Array> } {
return resp.body != null && typeof (resp.body as ReadableStream).getReader === 'function';
} Try / catch
if (!response.ok) { /* handled by error 25 path */ }
if (!hasReadableBody(response)) {
renderStaticResult(await fetchFullResearch(payload));
} Prevention
- Feature-detect ReadableStream responses at app start and disable/hide streaming-only UI in old runtimes.
- Provide a non-streaming endpoint fallback for locked-down browsers.
- In tests, polyfill ReadableStream (web-streams-polyfill) rather than mocking partial responses.
When it happens
Trigger: resp.ok is true and resp.body is undefined/null: old browsers (fetch streams shipped ~2017+), some WebViews/inline browsers, certain polyfilled fetch implementations (e.g. older whatwg-fetch) that lack body, or test environments (jsdom) without stream support.
Common situations: Users on legacy Chrome/Safari or in-app browsers; corporate environments replacing fetch with a polyfill; running the UI in jsdom-based tests; service-worker fetch interception stripping the body in old sw-toolbox versions.
Related errors
- 研究请求失败,状态码:${response.status}
- stream request failed: ${resp.status} ${message}
- 智能体流式请求失败: ${resp.status}
- 研究请求失败,状态码:${response.status}
- msg
AI-assisted analysis of datawhalechina/hello-agents@606a07d341 (2026-08-14).
Data as JSON: /api/errors/183271b0b09e1325.
Report an issue: GitHub.