zed-industries/zed · warning

SSH connection canceled

Error message

SSH connection canceled

What it means

During SSH connection establishment Zed races the askpass credential prompt against the master connection; if the user dismisses the prompt (AskPassResult::CancelledByUser), the master process is killed and this error aborts the connect. It is deliberate, user-driven cancellation rather than a malfunction.

Source

Thrown at crates/remote/src/transport/ssh.rs:687

            delegate.set_status(Some("Connecting"), cx);

            // Start the master SSH process, which does not do anything except
            // for establish the connection and keep it open, allowing other ssh
            // commands to reuse it via a control socket.
            let socket_path = temp_dir.path().join("ssh.sock");
            let mut master_process = MasterProcess::new(
                askpass.script_path().as_ref(),
                connection_options.additional_args(),
                &socket_path,
                &destination,
            )?;

            let result = select_biased! {
                result = askpass.run(Some(SSH_CONNECTION_PROMPT_TIMEOUT)).fuse() => {
                    match result {
                        AskPassResult::CancelledByUser => {
                            master_process.as_mut().kill().ok();
                            anyhow::bail!("SSH connection canceled")
                        }
                        AskPassResult::Timedout => {
                            anyhow::bail!("connecting to host timed out")
                        }
                    }
                }
                _ = master_process.wait_connected().fuse() => {
                    anyhow::Ok(())
                }
            };

            if let Err(e) = result {
                return Err(e.context("Failed to connect to host"));
            }

            if master_process.as_mut().try_status()?.is_some() {
                let mut output = Vec::new();
                let mut stderr = master_process.as_mut().stderr.take().unwrap();

View on GitHub (pinned to f4178619ac)

Solutions

  1. Retry the connection and complete the credential prompt
  2. Configure non-interactive auth so the prompt never appears: ssh-agent with the key loaded, or an empty-passphrase key
  3. For automation, supply credentials via SSH_ASKPASS helpers or key-based auth instead of interactive prompts
Defensive patterns

Strategy: try-catch

Try / catch

match connect(&opts, cx).await {
    Err(e) if e.to_string().contains("SSH connection canceled") => {
        // benign: user dismissed the prompt; do not retry, return to idle state
        Ok(None)
    }
    other => other.map(Some),
}

Prevention

When it happens

Trigger: Cancelling or dismissing the password/passphrase prompt shown while SshSocket is still connecting, causing select_biased! to resolve through the askpass branch, kill the master, and bail.

Common situations: Users backing out of a password dialog to fix a mistyped host or pick another key; prompts appearing unexpectedly so users dismiss them; headless test harnesses auto-dismissing dialogs.

Related errors


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/add3dcf7933e495b. Report an issue: GitHub.