{"record":{"id":"777a47d54aac1e07","repo":"astrid-runtime/astrid","slug":"daemon-response-timed-out-after-5s","errorCode":null,"errorMessage":"daemon response timed out after 5s","messagePattern":"daemon response timed out after 5s","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-cli/src/commands/doctor.rs","lineNumber":238,"sourceCode":"}\n\nfn check_fail(name: &str, detail: &str) {\n    println!(\"  [{}]  {} — {}\", \"FAIL\".red().bold(), name.bold(), detail);\n}\n\nasync fn daemon_roundtrip() -> Result<()> {\n    let mut client = tokio::time::timeout(\n        Duration::from_secs(5),\n        crate::socket_client::connect_kernel_for_workspace(None),\n    )\n    .await\n    .map_err(|_| anyhow::anyhow!(\"connection timed out after 5s\"))??;\n    match tokio::time::timeout(\n        Duration::from_secs(5),\n        client.request(KernelRequest::GetStatus),\n    )\n    .await\n    .map_err(|_| anyhow::anyhow!(\"daemon response timed out after 5s\"))??\n    {\n        KernelResponse::Status(_) => Ok(()),\n        KernelResponse::Error(message) => {\n            Err(anyhow::anyhow!(\"daemon rejected status request: {message}\"))\n        },\n        _ => Err(anyhow::anyhow!(\n            \"daemon returned an unexpected status response\"\n        )),\n    }\n}\n\n/// Query the daemon for agent-loop readiness over the same socket the\n/// other daemon-dependent checks use. Rides the existing\n/// `astrid.v1.request.` ingress allowlist prefix — no capsule change needed.\nasync fn agent_readiness() -> Result<astrid_core::kernel_api::AgentLoopReadiness> {\n    let mut client = tokio::time::timeout(\n        Duration::from_secs(5),\n        crate::socket_client::connect_kernel_for_workspace(None),","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-cli/src/commands/doctor.rs#L220-L256","documentation":"The second half of doctor's daemon_roundtrip: after connecting, the GetStatus request itself is wrapped in a 5-second timeout. Elapsing it raises this error, meaning the daemon accepted the connection but did not answer GetStatus within 5s — the daemon is reachable but unresponsive (busy, deadlocked, or its request loop is stuck).","triggerScenarios":"daemon_roundtrip sends KernelRequest::GetStatus and the daemon neither replies nor errors within 5s: event loop blocked on a long task, deadlocked handler, kernel busy on a huge workspace index, or a wedged channel between the socket listener and the kernel.","commonSituations":"Large workspaces making status computation slow; daemon thread panics leaving the request loop hung; resource exhaustion (CPU/memory) on the host; an in-flight long operation (reindex) monopolizing the kernel.","solutions":["Restart the daemon and retry `astrid doctor`.","Check daemon logs for a blocked/panicked handler around the time of the request.","Retry when the daemon is idle (no reindex/long job running).","If reproducible, capture a stack dump of the daemon to find the blocked call site."],"exampleFix":"// before\n$ astrid doctor\nError: daemon response timed out after 5s\n// after\n$ astrid daemon restart && astrid doctor  # daemon roundtrip: ok","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match daemon_roundtrip().await {\n    Err(e) if e.to_string().contains(\"daemon response timed out\") => {\n        eprintln!(\"daemon unresponsive — restart it and retry\");\n        restart_daemon().await?;\n    },\n    other => other?,\n}","preventionTips":["Keep the daemon's request loop non-blocking; offload long jobs.","Avoid running doctor while the kernel is reindexing.","Monitor daemon health/memory on large workspaces.","Add panic recovery around kernel handlers."],"tags":["timeout","ipc","daemon","unresponsive"],"backgroundTag":"request-timeout","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}