{"record":{"id":"34cf83a00a27fde4","repo":"sinelaw/fresh","slug":"the-fresh-editor-accepted-the-connection-but-did-not-answer","errorCode":null,"errorMessage":"the Fresh editor accepted the connection but did not answer within {:?}. It may be busy, or running a build without command-channel support; raise the wait with FRESH_CMD_TIMEOUT_MS if it is merely slow.","messagePattern":"the Fresh editor accepted the connection but did not answer within (.+?)\\. It may be busy, or running a build without command-channel support; raise the wait with FRESH_CMD_TIMEOUT_MS if it is merely slow\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fresh-editor/src/main.rs","lineNumber":3605,"sourceCode":"/// The default wait: enough for any command that answers off the editor thread.\nfn cmd_reply_timeout() -> std::time::Duration {\n    cmd_reply_timeout_or(std::time::Duration::from_secs(10))\n}\n\n/// The wait for a command that builds something first. A workspace create adds\n/// a git worktree and starts an agent, which on a large repository is seconds,\n/// not milliseconds — timing that out and reporting failure would be wrong\n/// about a create that is merely still running.\nfn cmd_build_timeout() -> std::time::Duration {\n    cmd_reply_timeout_or(std::time::Duration::from_secs(180))\n}\n\n/// Turn a bounded-read failure into an actionable message. A timeout here means\n/// the editor accepted the connection but never answered — the signature of a\n/// build whose event loop doesn't drain the control socket.\nfn cmd_read_error(e: std::io::Error) -> anyhow::Error {\n    if e.kind() == std::io::ErrorKind::TimedOut {\n        anyhow::anyhow!(\n            \"the Fresh editor accepted the connection but did not answer within {:?}. \\\n             It may be busy, or running a build without command-channel support; \\\n             raise the wait with FRESH_CMD_TIMEOUT_MS if it is merely slow.\",\n            cmd_reply_timeout()\n        )\n    } else {\n        anyhow::Error::from(e)\n    }\n}\n\n/// A live command-channel connection: the socket plus the reader that carries\n/// bytes buffered between replies. One reader for the whole exchange — a fresh\n/// one per read would drop anything that arrived in the same chunk as the\n/// previous message.\nstruct CmdConnection {\n    conn: fresh::server::ipc::ClientConnection,\n    reader: fresh::server::ipc::ControlReader,\n}","sourceCodeStart":3587,"sourceCodeEnd":3623,"githubUrl":"https://github.com/sinelaw/fresh/blob/67894ca5463dbd7a89bb31add4627c27d6b79d83/crates/fresh-editor/src/main.rs#L3587-L3623","documentation":"Mapped by `cmd_read_error` when the bounded read on the command channel returns `ErrorKind::TimedOut`: the editor accepted the connection but never sent a reply within `cmd_reply_timeout()` (configurable via FRESH_CMD_TIMEOUT_MS). Fresh distinguishes this from a refused/denied connection so users know the editor is alive but unresponsive on the command channel.","triggerScenarios":"Sending a command to a running editor whose event loop doesn't drain the control socket within the timeout — notably a build of Fresh without command-channel support, or one busy with a long operation.","commonSituations":"Older/newer editor build lacking the command channel; editor blocked on a modal prompt or long-running task; default timeout too short on a heavily loaded machine.","solutions":["Set FRESH_CMD_TIMEOUT_MS to a larger value and retry if the editor is merely slow.","Confirm the running editor build supports the command channel; restart it with a current build.","Check whether the editor is blocked (modal dialog, hung task) and resolve that, then retry.","Retry the command once the editor is idle."],"exampleFix":"// before: default timeout too low\n$ fresh-cli cmd \"save-all\"   # times out at default\n// after: raise the wait\n$ FRESH_CMD_TIMEOUT_MS=10000 fresh-cli cmd \"save-all\"","handlingStrategy":"retry","validationCode":"// pre-flight: confirm the editor drains the command channel quickly\nfn responds_quickly(p: &std::path::Path, ms: u64) -> bool {\n    // attempt a cheap ping with a short deadline\n    ping_with_timeout(p, std::time::Duration::from_millis(ms)).is_ok()\n}","typeGuard":null,"tryCatchPattern":"match send_command(cmd) {\n    Err(e) if e.to_string().contains(\"did not answer within\") => {\n        std::env::set_var(\"FRESH_CMD_TIMEOUT_MS\", \"10000\");\n        retry_once(cmd)?\n    }\n    other => other?,\n}","preventionTips":["Set FRESH_CMD_TIMEOUT_MS generously on loaded machines","Verify the editor build supports the command channel before scripting it","Avoid sending commands while the editor is blocked on a modal task","Retry once after a timeout before giving up"],"tags":["timeout","ipc","command-channel","cli"],"backgroundTag":"request-timeout","analyzedSha":"67894ca5463dbd7a89bb31add4627c27d6b79d83","analyzedAt":"2026-09-13T15:04:03.701Z","contentChangedAt":"2026-09-13T15:04:03.701Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}