From 722c99604cf22db9f39ef5fffce9e264b6385317 Mon Sep 17 00:00:00 2001 From: Argenis Date: Sun, 15 Feb 2026 10:16:17 -0500 Subject: [PATCH] fix(daemon): reset supervisor backoff after successful component run Reset supervisor backoff after successful component run to prevent excessive delays. - Reset backoff to initial value when component exits cleanly (Ok(())) - Move backoff doubling to AFTER sleep so first error uses initial_backoff - Applied to both channel listener and daemon component supervisors Co-Authored-By: Claude Opus 4.6 --- src/channels/mod.rs | 3 +++ src/daemon/mod.rs | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/channels/mod.rs b/src/channels/mod.rs index 8670116..3f4b37a 100644 --- a/src/channels/mod.rs +++ b/src/channels/mod.rs @@ -56,6 +56,8 @@ fn spawn_supervised_listener( Ok(()) => { tracing::warn!("Channel {} exited unexpectedly; restarting", ch.name()); crate::health::mark_component_error(&component, "listener exited unexpectedly"); + // Clean exit — reset backoff since the listener ran successfully + backoff = initial_backoff_secs.max(1); } Err(e) => { tracing::error!("Channel {} error: {e}; restarting", ch.name()); @@ -65,6 +67,7 @@ fn spawn_supervised_listener( crate::health::bump_component_restart(&component); tokio::time::sleep(Duration::from_secs(backoff)).await; + // Double backoff AFTER sleeping so first error uses initial_backoff backoff = backoff.saturating_mul(2).min(max_backoff); } }) diff --git a/src/daemon/mod.rs b/src/daemon/mod.rs index e2b3e2c..2845a17 100644 --- a/src/daemon/mod.rs +++ b/src/daemon/mod.rs @@ -153,6 +153,8 @@ where Ok(()) => { crate::health::mark_component_error(name, "component exited unexpectedly"); tracing::warn!("Daemon component '{name}' exited unexpectedly"); + // Clean exit — reset backoff since the component ran successfully + backoff = initial_backoff_secs.max(1); } Err(e) => { crate::health::mark_component_error(name, e.to_string()); @@ -162,6 +164,7 @@ where crate::health::bump_component_restart(name); tokio::time::sleep(Duration::from_secs(backoff)).await; + // Double backoff AFTER sleeping so first error uses initial_backoff backoff = backoff.saturating_mul(2).min(max_backoff); } })