{"record":{"id":"3dd5c704f5a2cc52","repo":"zed-industries/zed","slug":"failed-to-set-url-scheme-3dd5c7","errorCode":null,"errorMessage":"failed to set URL scheme","messagePattern":"failed to set URL scheme","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cloud_api_client/src/websocket/web.rs","lineNumber":65,"sourceCode":"        (message_rx.into_stream().boxed(), task)\n    }\n}\n\nimpl CloudApiClient {\n    pub fn connect(self: &std::sync::Arc<Self>, cx: &App) -> Result<Task<Result<Connection>>> {\n        let client = self.clone();\n        let executor = cx.background_executor().clone();\n        Ok(cx.spawn(async move |_cx| {\n            let mut connect_url = client\n                .http_client\n                .build_zed_cloud_url(\"/client/users/connect\")?;\n            connect_url\n                .set_scheme(match connect_url.scheme() {\n                    \"https\" => \"wss\",\n                    \"http\" => \"ws\",\n                    scheme => return Err(anyhow!(\"invalid URL scheme: {scheme}\")),\n                })\n                .map_err(|_| anyhow!(\"failed to set URL scheme\"))?;\n\n\n            let connect = WebSocket::connect(connect_url).fuse();\n            let timeout = executor.timer(CONNECT_TIMEOUT).fuse();\n            futures::pin_mut!(connect, timeout);\n            let websocket = futures::select_biased! {\n                result = connect => result.map_err(|error| anyhow!(\"failed to connect to Cloud WebSocket: {error}\"))?,\n                _ = timeout => return Err(anyhow!(\"timed out connecting to Cloud WebSocket\")),\n            };\n\n            Ok(Connection::new(websocket))\n        }))\n    }\n}\n","sourceCodeStart":47,"sourceCodeEnd":80,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/crates/cloud_api_client/src/websocket/web.rs#L47-L80","documentation":"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.","triggerScenarios":"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.","commonSituations":"Hand-built base URLs missing the hostname; reverse proxies emitting relative Location values.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if connect_url.host_str().is_none() {\n    return Err(anyhow!(\"cloud URL has no host: {connect_url}\"));\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check host presence before rewriting schemes","Ensure proxies return absolute URLs in redirects","Unit-test set_scheme behavior for every supported base URL"],"tags":["configuration","url","wasm"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}