diff --git a/apps/monitor/src/main.rs b/apps/monitor/src/main.rs index 39cf5c0..05ac45a 100644 --- a/apps/monitor/src/main.rs +++ b/apps/monitor/src/main.rs @@ -41,6 +41,6 @@ async fn main() -> Result<()> { Ok(n) => { if n > 0 { info!("Spawned {n} checks"); } }, Err(e) => error!("Check cycle failed: {e}"), } - sleep(Duration::from_millis(500)).await; + sleep(Duration::from_millis(50)).await; } } diff --git a/apps/monitor/src/runner.rs b/apps/monitor/src/runner.rs index e5edcd7..d7ef573 100644 --- a/apps/monitor/src/runner.rs +++ b/apps/monitor/src/runner.rs @@ -61,11 +61,12 @@ pub async fn fetch_and_run( meta: None, }, }; - // Remove from in-flight before posting so a fast next cycle can pick it up - in_flight.lock().await.remove(&monitor.id); + // Post result first, then clear in-flight — this prevents the next + // poll from picking up the monitor again before the ping is persisted. if let Err(e) = post_result(&client, &coordinator_url, &token, result).await { warn!("Failed to post result for {}: {e}", monitor.id); } + in_flight.lock().await.remove(&monitor.id); }); }