diff --git a/hive-agent/src/todo_server.rs b/hive-agent/src/todo_server.rs index 5e56f8a4..6d755dad 100644 --- a/hive-agent/src/todo_server.rs +++ b/hive-agent/src/todo_server.rs @@ -43,6 +43,10 @@ use crate::todos::{Todo, Todos}; /// dashboard's `ctx·Nk` badge before hitting the `/compact` button. const COMPACT_MIN_USAGE_FRACTION: f64 = 0.66; +/// Pause after a failed `accept`, so a failure that persists (fd exhaustion) +/// does not turn the accept loop into a busy spin. +const ACCEPT_RETRY_DELAY: std::time::Duration = std::time::Duration::from_secs(1); + /// Resolve the in-agent socket path from `HIVE_AGENT_SOCKET`. `None` when /// unset/empty (e.g. a standalone dev run) — the server then stays off. fn socket_path() -> Option { @@ -107,7 +111,12 @@ pub async fn run( } }); } - Err(e) => tracing::warn!(error = ?e, "in-agent todo accept failed"), + Err(e) => { + tracing::warn!(error = ?e, "in-agent todo accept failed"); + // A persistent failure (fd exhaustion) fails again at once; + // without a pause this loop spins and floods the log. + tokio::time::sleep(ACCEPT_RETRY_DELAY).await; + } } } }