From 9b970a90e069a909b36e2955b6b13ff83336713f Mon Sep 17 00:00:00 2001 From: M1 Date: Mon, 16 Mar 2026 15:37:00 +0400 Subject: [PATCH] fix: fire-and-forget checks so slow monitors don't delay fast ones --- apps/monitor/Cargo.toml | 1 - apps/monitor/src/runner.rs | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/apps/monitor/Cargo.toml b/apps/monitor/Cargo.toml index 5bb15bc..8e2b7db 100644 --- a/apps/monitor/Cargo.toml +++ b/apps/monitor/Cargo.toml @@ -9,7 +9,6 @@ reqwest = { version = "0.12", features = ["json", "rustls-tls"], default-fe serde = { version = "1", features = ["derive"] } serde_json = "1" scraper = "0.21" # CSS selector / HTML parsing -futures = "0.3" regex = "1" anyhow = "1" tracing = "0.1" diff --git a/apps/monitor/src/runner.rs b/apps/monitor/src/runner.rs index 96a2b16..ab50826 100644 --- a/apps/monitor/src/runner.rs +++ b/apps/monitor/src/runner.rs @@ -25,8 +25,8 @@ pub async fn fetch_and_run( let n = monitors.len(); if n == 0 { return Ok(0); } - // Run all checks concurrently - let tasks: Vec<_> = monitors.into_iter().map(|monitor| { + // Spawn all checks — fire and forget, don't block the cycle + for monitor in monitors { let client = client.clone(); let coordinator_url = coordinator_url.to_string(); let token = token.to_string(); @@ -35,10 +35,9 @@ pub async fn fetch_and_run( if let Err(e) = post_result(&client, &coordinator_url, &token, result).await { warn!("Failed to post result for {}: {e}", monitor.id); } - }) - }).collect(); + }); + } - futures::future::join_all(tasks).await; Ok(n) }