← ClaudeAtlas

polling-bot-backlog-diagnosislisted

Diagnose and fix message backlog and notification-spam issues in cron-based polling bots — covers per-run deduplication flags and stale-message age filters
williamblair333/Uncle-J-s-Refinery · ★ 3 · AI & Automation · score 76
Install: claude install-skill williamblair333/Uncle-J-s-Refinery
## When to use When a cron-based polling bot (Telegram, Slack, etc.) shows either of these symptoms: - Multiple identical notification messages per cron run (e.g., "⚠️ Message limit reached" appearing 4× instead of once) - A stale backlog consuming the full rate-limit budget on every reset cycle (e.g., 20 "⏳ Running…" messages over 40 min, then rate limit hit, then repeat) ## Root causes and fixes ### Bug 1: Multiple notifications per cron run **Symptom:** Each queued message triggers its own rate-limit or error notification. N queued messages → N notifications per run. **Root cause:** The notification flag is checked per-message rather than per-run. **Fix:** Set a `rate_limit_notified = False` flag before the message loop. Inside the loop, only send the notification on the first hit and flip the flag. All subsequent rate-limited messages in the same run are silently dropped (advance offsets so they don't reprocess). rate_limit_notified = False for message in pending_messages: if rate_limited: if not rate_limit_notified: send("⚠️ Message limit reached") rate_limit_notified = True advance_offset(message) continue process(message) ### Bug 2: Stale backlog consuming rate-limit budget **Symptom:** Bot processes messages from hours ago on every cron cycle, burning all hourly slots before reaching fresh messages. **Root cause:** No message age check — the bot processes everything in the queue regardless of when it wa