fix: clear in-flight after post_result to prevent double-pings, revert poll to 50ms

This commit is contained in:
M1 2026-03-18 14:29:37 +04:00
parent d3ee0ef9d5
commit 957674fca4
2 changed files with 4 additions and 3 deletions

View File

@ -41,6 +41,6 @@ async fn main() -> Result<()> {
Ok(n) => { if n > 0 { info!("Spawned {n} checks"); } }, Ok(n) => { if n > 0 { info!("Spawned {n} checks"); } },
Err(e) => error!("Check cycle failed: {e}"), Err(e) => error!("Check cycle failed: {e}"),
} }
sleep(Duration::from_millis(500)).await; sleep(Duration::from_millis(50)).await;
} }
} }

View File

@ -61,11 +61,12 @@ pub async fn fetch_and_run(
meta: None, meta: None,
}, },
}; };
// Remove from in-flight before posting so a fast next cycle can pick it up // Post result first, then clear in-flight — this prevents the next
in_flight.lock().await.remove(&monitor.id); // poll from picking up the monitor again before the ping is persisted.
if let Err(e) = post_result(&client, &coordinator_url, &token, result).await { if let Err(e) = post_result(&client, &coordinator_url, &token, result).await {
warn!("Failed to post result for {}: {e}", monitor.id); warn!("Failed to post result for {}: {e}", monitor.id);
} }
in_flight.lock().await.remove(&monitor.id);
}); });
} }