zed-industries/zed · error

fetch result is not a Response: {error:?}

Error message

fetch result is not a Response: {error:?}

What it means

Guard in the wasm fetch: the fetch Promise resolved to a value that dyn_into failed to cast into a web_sys::Response — {error:?} is the wasm-bindgen conversion error. The browser returned something other than a Response object, which should not normally happen and indicates an environment/interop anomaly.

Source

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

    let request_headers = request.headers();
    for (name, value) in &parts.headers {
        let value_str = value
            .to_str()
            .map_err(|_| anyhow!("non-ASCII header value for {name}"))?;
        request_headers
            .set(name.as_str(), value_str)
            .map_err(|error| anyhow!("failed to set header {name}: {error:?}"))?;
    }

    let promise =
        global_fetch(&request).map_err(|error| anyhow!("fetch threw an error: {error:?}"))?;
    let response_value = wasm_bindgen_futures::JsFuture::from(promise)
        .await
        .map_err(|error| anyhow!("fetch failed: {error:?}"))?;

    let web_response: web_sys::Response = response_value
        .dyn_into()
        .map_err(|error| anyhow!("fetch result is not a Response: {error:?}"))?;

    let status = web_response.status();
    let mut builder = http_client::http::Response::builder().status(status);

    // `Headers` is a JS iterable yielding `[name, value]` pairs.
    // `js_sys::Array::from` calls `Array.from()` which accepts any iterable.
    let header_pairs = js_sys::Array::from(&web_response.headers());
    for index in 0..header_pairs.length() {
        match header_pairs.get(index).dyn_into::<js_sys::Array>() {
            Ok(pair) => match (pair.get(0).as_string(), pair.get(1).as_string()) {
                (Some(name), Some(value)) => {
                    builder = builder.header(name, value);
                }
                (name, value) => {
                    log::warn!(
                        "skipping response header at index {index}: \
                                     name={name:?}, value={value:?}"
                    );

View on GitHub (pinned to f4178619ac)

Solutions

  1. Log the actual JS type (JS::typeof / constructor name) to diagnose the environment
  2. Ensure fetch is not shimmed/monkey-patched by other scripts returning non-Response values
  3. Fail the request future with a descriptive error rather than attempting to continue
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/gpui_web/src/http_client.rs:156 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/a321b34ebda1eef3. Report an issue: GitHub.