zed-industries/zed · error

failed to create fetch Request: {error:?}

Error message

failed to create fetch Request: {error:?}

What it means

Guard in the wasm HTTP client's fetch: constructing the web_sys::Request from the URL string and RequestInit failed, i.e. the browser rejected the request before any network I/O. {error:?} is a JS TypeError, typically an unparseable URL/relative URL in a non-window context or an invalid body/init combination.

Source

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

    if let Some(redirect_policy) = parts.extensions.get::<RedirectPolicy>() {
        match redirect_policy {
            RedirectPolicy::NoFollow => {
                init.set_redirect(web_sys::RequestRedirect::Manual);
            }
            RedirectPolicy::FollowLimit(_) | RedirectPolicy::FollowAll => {
                init.set_redirect(web_sys::RequestRedirect::Follow);
            }
        }
    }

    if let Some(ref bytes) = body_bytes {
        let uint8array = js_sys::Uint8Array::from(bytes.as_slice());
        init.set_body(uint8array.as_ref());
    }

    let url = parts.uri.to_string();
    let request = web_sys::Request::new_with_str_and_init(&url, &init)
        .map_err(|error| anyhow!("failed to create fetch Request: {error:?}"))?;

    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

View on GitHub (pinned to f4178619ac)

Solutions

  1. Ensure the request URI is an absolute, valid URL before building the Request
  2. Check that body/init combination is legal for fetch (e.g. body with GET is rejected)
  3. Log the JS error and reject the caller's response future with a clear bad-request message
Defensive patterns

Strategy: try-catch

When it happens

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