zed-industries/zed · error

response body reader has an unexpected type: {error:?}

Error message

response body reader has an unexpected type: {error:?}

What it means

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.

Source

Thrown at crates/gpui_web/src/http_client.rs:189

                    log::warn!(
                        "skipping response header at index {index}: \
                                     name={name:?}, value={value:?}"
                    );
                }
            },
            Err(entry) => {
                log::warn!("skipping non-array header entry at index {index}: {entry:?}");
            }
        }
    }

    let body = match web_response.body() {
        Some(stream) => {
            let reader = stream
                .get_reader()
                .dyn_into::<web_sys::ReadableStreamDefaultReader>()
                .map_err(|error| {
                    anyhow!("response body reader has an unexpected type: {error:?}")
                })?;
            AsyncBody::from_reader(ReadableStreamBody::new(reader))
        }
        None => AsyncBody::empty(),
    };

    builder.body(body).map_err(|error| anyhow!(error))
}

// Request bodies are buffered into memory because streaming uploads require
// half-duplex Fetch support that browsers largely don't ship yet.
async fn read_body_to_bytes(mut body: AsyncBody) -> anyhow::Result<Option<Vec<u8>>> {
    let mut buffer = Vec::new();
    body.read_to_end(&mut buffer).await?;
    if buffer.is_empty() {
        Ok(None)
    } else {
        Ok(Some(buffer))

View on GitHub (pinned to f4178619ac)

Solutions

  1. Handle the None body case (204/304 responses) before getting a reader
  2. Fall back to web_sys::Response::text() or array_buffer() when streaming is unavailable
  3. Feature-detect ReadableStream support in the target browser environment
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/gpui_web/src/http_client.rs:189 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/848251093ed8f241. Report an issue: GitHub.