zed-industries/zed · error · anyhow::Error
invalid URL scheme: {scheme}
Error message
invalid URL scheme: {scheme} What it means
Web (wasm) build of the Cloud WebSocket connect: the /client/users/connect URL must switch https→wss or http→ws, and this error fires when the URL's scheme is anything else. Functionally identical to the native variant, but on the browser code path.
Source
Thrown at crates/cloud_api_client/src/websocket/web.rs:63
});
(message_rx.into_stream().boxed(), task)
}
}
impl CloudApiClient {
pub fn connect(self: &std::sync::Arc<Self>, cx: &App) -> Result<Task<Result<Connection>>> {
let client = self.clone();
let executor = cx.background_executor().clone();
Ok(cx.spawn(async move |_cx| {
let mut connect_url = client
.http_client
.build_zed_cloud_url("/client/users/connect")?;
connect_url
.set_scheme(match connect_url.scheme() {
"https" => "wss",
"http" => "ws",
scheme => return Err(anyhow!("invalid URL scheme: {scheme}")),
})
.map_err(|_| anyhow!("failed to set URL scheme"))?;
let connect = WebSocket::connect(connect_url).fuse();
let timeout = executor.timer(CONNECT_TIMEOUT).fuse();
futures::pin_mut!(connect, timeout);
let websocket = futures::select_biased! {
result = connect => result.map_err(|error| anyhow!("failed to connect to Cloud WebSocket: {error}"))?,
_ = timeout => return Err(anyhow!("timed out connecting to Cloud WebSocket")),
};
Ok(Connection::new(websocket))
}))
}
}
View on GitHub (pinned to bc538def45)
Solutions
- Configure the cloud base URL as https:// and let the code derive wss
- Verify the final connect URL scheme in browser devtools network panel
- Remove scheme-specific overrides from the web build config
Defensive patterns
Strategy: validation
Validate before calling
let connect_url = client.http_client.build_zed_cloud_url("/client/users/connect")?;
if !matches!(connect_url.scheme(), "http" | "https") {
return Err(anyhow!("cloud base URL must be http(s), got {}", connect_url.scheme()));
} Type guard
fn is_http_cloud_url(url: &url::Url) -> bool {
matches!(url.scheme(), "http" | "https") && url.host_str().is_some()
} Prevention
- Keep one URL builder shared between native and wasm paths so validation is identical
- Assert scheme in integration tests for the web build
- Document that custom cloud URLs must always be https
When it happens
Trigger: build_zed_cloud_url yields a scheme other than http/https on the wasm target — custom cloud base URL with wss:// or another scheme, or a hosting environment rewriting the base URL.
Common situations: Custom deployments of the web build with misconfigured base URLs; env vars intended for native leaking into web builds.
Related errors
- invalid URL scheme: {scheme}
- failed to set URL scheme
- failed to set URL scheme
- invalid rpc url: {}
- failed to connect to Cloud WebSocket: {error}
AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16).
Data as JSON: /api/errors/8bc805f8063d4c1f.
Report an issue: GitHub.