{"record":{"id":"848251093ed8f241","repo":"zed-industries/zed","slug":"response-body-reader-has-an-unexpected-type-erro","errorCode":null,"errorMessage":"response body reader has an unexpected type: {error:?}","messagePattern":"response body reader has an unexpected type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui_web/src/http_client.rs","lineNumber":189,"sourceCode":"                    log::warn!(\n                        \"skipping response header at index {index}: \\\n                                     name={name:?}, value={value:?}\"\n                    );\n                }\n            },\n            Err(entry) => {\n                log::warn!(\"skipping non-array header entry at index {index}: {entry:?}\");\n            }\n        }\n    }\n\n    let body = match web_response.body() {\n        Some(stream) => {\n            let reader = stream\n                .get_reader()\n                .dyn_into::<web_sys::ReadableStreamDefaultReader>()\n                .map_err(|error| {\n                    anyhow!(\"response body reader has an unexpected type: {error:?}\")\n                })?;\n            AsyncBody::from_reader(ReadableStreamBody::new(reader))\n        }\n        None => AsyncBody::empty(),\n    };\n\n    builder.body(body).map_err(|error| anyhow!(error))\n}\n\n// Request bodies are buffered into memory because streaming uploads require\n// half-duplex Fetch support that browsers largely don't ship yet.\nasync fn read_body_to_bytes(mut body: AsyncBody) -> anyhow::Result<Option<Vec<u8>>> {\n    let mut buffer = Vec::new();\n    body.read_to_end(&mut buffer).await?;\n    if buffer.is_empty() {\n        Ok(None)\n    } else {\n        Ok(Some(buffer))","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/gpui_web/src/http_client.rs#L171-L207","documentation":"Guard in the wasm fetch response-body streaming: web_response.body()'s reader could not be dyn_into'd to ReadableStreamDefaultReader — {error:?} is the cast error. The body stream is missing or a different reader type (e.g. null body, or a byte-stream variant), so the body cannot be read incrementally.","triggerScenarios":"Thrown at crates/gpui_web/src/http_client.rs:189 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Handle the None body case (204/304 responses) before getting a reader","Fall back to web_sys::Response::text() or array_buffer() when streaming is unavailable","Feature-detect ReadableStream support in the target browser environment"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}