astrid-runtime/astrid · error

connection timed out after 5s

Error message

connection timed out after 5s

What it means

The doctor daemon_roundtrip check wraps connect_kernel_for_workspace in a 5-second tokio timeout. If connecting to the astrid kernel daemon's unix socket does not complete within 5s, the timeout elapses and this error is raised, independent of the underlying connect error (which is discarded by the map_err on the elapsed branch).

Source

Thrown at crates/astrid-cli/src/commands/doctor.rs:232

    println!(
        "  [{}]  {} — {}",
        "WARN".yellow().bold(),
        name.bold(),
        detail
    );
}

fn check_fail(name: &str, detail: &str) {
    println!("  [{}]  {} — {}", "FAIL".red().bold(), name.bold(), detail);
}

async fn daemon_roundtrip() -> Result<()> {
    let mut client = tokio::time::timeout(
        Duration::from_secs(5),
        crate::socket_client::connect_kernel_for_workspace(None),
    )
    .await
    .map_err(|_| anyhow::anyhow!("connection timed out after 5s"))??;
    match tokio::time::timeout(
        Duration::from_secs(5),
        client.request(KernelRequest::GetStatus),
    )
    .await
    .map_err(|_| anyhow::anyhow!("daemon response timed out after 5s"))??
    {
        KernelResponse::Status(_) => Ok(()),
        KernelResponse::Error(message) => {
            Err(anyhow::anyhow!("daemon rejected status request: {message}"))
        },
        _ => Err(anyhow::anyhow!(
            "daemon returned an unexpected status response"
        )),
    }
}

/// Query the daemon for agent-loop readiness over the same socket the

View on GitHub (pinned to affd8760f4)

Solutions

  1. Start or restart the astrid daemon, then re-run `astrid doctor`.
  2. Check the socket file exists at the expected workspace path and remove stale sockets.
  3. Retry after machine wake-up or heavy load; if intermittent, investigate daemon responsiveness.
  4. Look at daemon logs to see why it is not accepting connections.

Example fix

// before: doctor fails with timeout
$ astrid doctor
Error: connection timed out after 5s
// after
$ astrid daemon start && astrid doctor  # status: ok
Defensive patterns

Strategy: retry

Validate before calling

// Pre-check the socket exists before attempting connect
let sock = astrid_socket_path(None)?;
if !sock.exists() { eprintln!("daemon socket missing — is the daemon running?"); }

Try / catch

match daemon_roundtrip().await {
    Err(e) if e.to_string().contains("connection timed out") => {
        // start the daemon, then retry once
        start_daemon().await?;
        daemon_roundtrip().await?;
    },
    other => other?,
}

Prevention

When it happens

Trigger: `astrid doctor` (run -> daemon_roundtrip) when the kernel daemon is not running, the socket path is stale, the daemon is wedged and not accepting connections, or the system is so loaded the connect handshake exceeds 5s.

Common situations: Daemon crashed or was killed; machine asleep/resumed leaving a stale socket; running doctor in a container/WSL where the socket isn't shared; daemon startup still in progress.

Understand the failure class

Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.

Related errors


AI-assisted analysis of astrid-runtime/astrid@affd8760f4 (2026-09-09). Data as JSON: /api/errors/99675a083a56ef22. Report an issue: GitHub.