zed-industries/zed · error · anyhow::Error
failed to set URL scheme
Error message
failed to set URL scheme
What it means
Web (wasm) build: after scheme mapping, url.set_scheme to ws/wss failed because the URL's shape does not permit that scheme change (e.g. missing host). The connect URL could not be rewritten, so the connection aborts before starting.
Source
Thrown at crates/cloud_api_client/src/websocket/web.rs:65
(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
- Use an absolute base URL with an explicit host
- Validate the parsed URL has host_str() Some(...) before connecting
- Check any proxy in front of the cloud API preserves absolute URLs
Defensive patterns
Strategy: validation
Validate before calling
if connect_url.host_str().is_none() {
return Err(anyhow!("cloud URL has no host: {connect_url}"));
} Prevention
- Check host presence before rewriting schemes
- Ensure proxies return absolute URLs in redirects
- Unit-test set_scheme behavior for every supported base URL
When it happens
Trigger: set_scheme errors on the wasm path when the built connect URL lacks a host or has an incompatible structure — malformed base URL or a host-stripping proxy.
Common situations: Hand-built base URLs missing the hostname; reverse proxies emitting relative Location values.
Related errors
- invalid URL scheme: {scheme}
- invalid rpc url: {}
- invalid URL scheme: {scheme}
- failed to set URL scheme
- No eval-cli binary provided. Either pass binary_path=/path/t
AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16).
Data as JSON: /api/errors/3dd5c704f5a2cc52.
Report an issue: GitHub.