From 8b37bd432395e08220ab221aa5dcc5c1fb6bd115 Mon Sep 17 00:00:00 2001 From: Siavash Sameni Date: Sun, 29 Mar 2026 12:25:41 +0400 Subject: [PATCH] fix: getUpdates enforces min 1s delay when empty (prevents tight-loop spam) Co-Authored-By: Claude Opus 4.6 (1M context) --- warzone/crates/warzone-server/src/routes/bot.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/warzone/crates/warzone-server/src/routes/bot.rs b/warzone/crates/warzone-server/src/routes/bot.rs index 05b7072..5cba6c7 100644 --- a/warzone/crates/warzone-server/src/routes/bot.rs +++ b/warzone/crates/warzone-server/src/routes/bot.rs @@ -453,8 +453,9 @@ async fn get_updates( // Step 3: Collect remaining updates up to `limit`. let updates = collect_updates(&state, bot_fp, limit); - // Step 4: Long-poll if empty. - if updates.is_empty() && timeout > 0 { + // Step 4: Long-poll if empty. Minimum 1s delay to prevent tight-loop abuse. + if updates.is_empty() { + let timeout = if timeout == 0 { 1 } else { timeout }; // force min 1s let wait = std::cmp::min(timeout, 50); // Poll in 1-second intervals so new messages are picked up promptly. let deadline = tokio::time::Instant::now() + std::time::Duration::from_secs(wait);