zed-industries/zed · error · anyhow::Error

failed to connect to Cloud WebSocket: {error}

Error message

failed to connect to Cloud WebSocket: {error}

What it means

Web (wasm) build: the WebSocket::connect future raced against a CONNECT_TIMEOUT timer and the connect side finished with an error, which is wrapped with this message. The TCP/TLS/websocket handshake to the Cloud endpoint failed outright.

Source

Thrown at crates/cloud_api_client/src/websocket/web.rs:72

        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

  1. Verify wss connectivity to the cloud host (browser devtools or `curl --include --no-buffer https://host/client/users/connect -H 'Connection: Upgrade' -H 'Upgrade: websocket'`)
  2. Allow websocket traffic through firewalls/proxies (wss on 443)
  3. Check https://status.zed.dev and retry after the endpoint recovers
Defensive patterns

Strategy: retry

Try / catch

let websocket = futures::select_biased! {
    result = connect => match result {
        Ok(ws) => ws,
        Err(error) => {
            // handshake failed: backoff, then one bounded retry
            executor.timer(Duration::from_secs(2)).await;
            WebSocket::connect(connect_url.clone()).await?
        }
    },
    _ = timeout => return Err(anyhow!("timed out connecting to Cloud WebSocket")),
};

Prevention

When it happens

Trigger: WebSocket::connect errors within the timeout: DNS failure, blocked wss port, TLS certificate rejection, proxy refusing websocket upgrades, or server unreachable.

Common situations: Corporate firewalls blocking outbound wss; browser security policies; cloud API endpoint temporarily down; self-signed certificates in test environments.

Related errors


AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16). Data as JSON: /api/errors/0cc37bbcdd86e180. Report an issue: GitHub.