Repository navigation
fix: resume the reaction resweep within the run once a FloodWait expires (#224) - #226
Conversation
…xpires (#224) Deferring the entire rest of a run on the first FloodWait over-corrected on accounts with small flood buckets: a ~1-minute window turned into hours of cycle latency (one production report covered 2 chats and deferred 498 where the previous behavior covered the full eligible set in one run). The resweep now records the flood expiry and pauses - nothing sleeps, nothing retries, no second-bucket fallback - then resumes within the same run once the server-requested window (plus a 2s margin) has elapsed. Chats reached while cooling down and the window outliving the run still defer to the cycle cursor exactly as before, and after three floods in one run the remainder defers outright since a repeatedly-flooding bucket should be left alone. Adds README sizing guidance for REACTION_RESWEEP_MAX_PER_CHAT on small-bucket accounts. Bumps version to 7.25.1.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe reaction resweep now pauses and resumes within the same run after FloodWait responses, tracks partial progress, hard-defers after repeated floods, persists deferred state, updates tests and documentation, and bumps the package version to 7.25.1. ChangesReaction resweep updates
Estimated code review effort: 3 (Moderate) | ~25 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #226 +/- ##
==========================================
+ Coverage 93.51% 93.53% +0.01%
==========================================
Files 27 27
Lines 8092 8115 +23
==========================================
+ Hits 7567 7590 +23
Misses 525 525
🚀 New features to boost your workflow:
|
|
🐳 Dev images published!
The dev/test instance will pick up these changes automatically (Portainer GitOps). To test locally: docker pull drumsergio/telegram-archive:dev
docker pull drumsergio/telegram-archive-viewer:dev |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@README.md`:
- Around line 407-409: Update the re-sweep documentation around the persisted
per-cycle progress to avoid promising exact resume positions: replace “resumes
exactly where the last one stopped” with wording that clearly states resumption
is approximate, while preserving the surrounding behavior description.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: d7950840-7a94-4d76-bab0-6ba2992c9db0
📒 Files selected for processing (5)
README.mdpyproject.tomlsrc/__init__.pysrc/telegram_backup.pytests/test_reaction_resweep.py
|
CodeRabbit's wording catch fixed in the latest commit — the cursor resumes approximately where the previous run stopped (the window shifts between runs; the idempotent reconcile makes overlap harmless), matching what the code comments already said. |
|
🐳 Dev images published!
The dev/test instance will pick up these changes automatically (Portainer GitOps). To test locally: docker pull drumsergio/telegram-archive:dev
docker pull drumsergio/telegram-archive-viewer:dev |
… logs and offset advance Panel findings: .env.example and one raw-path comment still described the superseded defer-on-first-flood behavior; the pacing test class docstring likewise. Adds a PII guard test over the new flood/pause/resume log lines and a double-flood-same-chat test proving the parked mid-chat offset advances instead of resetting.
|
Ran a 3-perspective panel (state-machine logic, adversarial behavior, tests) with adversarial verification: zero serious findings — the pause/resume state machine verified sound on gate order, cap-trip progress parking, exact finalize keying, double-count immunity, and clock discipline. Five doc/test findings all addressed in the latest commit: stale defer-on-first-flood narratives in .env.example, one code comment, and the test-class docstring; plus two new tests (PII guard over the flood/pause/resume log lines, and a double-flood-on-one-chat case proving the parked offset advances rather than resetting). 2271 tests green. |
|
🐳 Dev images published!
The dev/test instance will pick up these changes automatically (Portainer GitOps). To test locally: docker pull drumsergio/telegram-archive:dev
docker pull drumsergio/telegram-archive-viewer:dev |
|
@coderabbitai full review |
✅ Action performedFull review finished. Your plan includes PR reviews subject to rate limits. More reviews will be available in 9 minutes. |
|
@coderabbitai full review |
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@README.md`:
- Around line 407-409: Update the FloodWait-related environment-variable table
entry near the existing resweep settings to match the current behavior described
in the re-sweep documentation and .env.example: the first FloodWait should pause
and resume within the same run when possible, deferring only when the wait
exceeds the run or repeated floods occur. Remove the stale statement that
immediately defers the remaining resweep after the first FloodWait.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 728d1046-83de-4f71-a215-ccb4be3f0c99
📒 Files selected for processing (6)
.env.exampleREADME.mdpyproject.tomlsrc/__init__.pysrc/telegram_backup.pytests/test_reaction_resweep.py
|
Last stale narrative fixed — the env-table row for |
|
🐳 Dev images published!
The dev/test instance will pick up these changes automatically (Portainer GitOps). To test locally: docker pull drumsergio/telegram-archive:dev
docker pull drumsergio/telegram-archive-viewer:dev |
…res (#224) (#226) * fix(reactions): resume the resweep within the run after a FloodWait expires (#224) Deferring the entire rest of a run on the first FloodWait over-corrected on accounts with small flood buckets: a ~1-minute window turned into hours of cycle latency (one production report covered 2 chats and deferred 498 where the previous behavior covered the full eligible set in one run). The resweep now records the flood expiry and pauses - nothing sleeps, nothing retries, no second-bucket fallback - then resumes within the same run once the server-requested window (plus a 2s margin) has elapsed. Chats reached while cooling down and the window outliving the run still defer to the cycle cursor exactly as before, and after three floods in one run the remainder defers outright since a repeatedly-flooding bucket should be left alone. Adds README sizing guidance for REACTION_RESWEEP_MAX_PER_CHAT on small-bucket accounts. Bumps version to 7.25.1. * docs(readme): resume position is approximate, not exact * docs+tests(review): align narratives with pause-and-resume, guard PII logs and offset advance Panel findings: .env.example and one raw-path comment still described the superseded defer-on-first-flood behavior; the pacing test class docstring likewise. Adds a PII guard test over the new flood/pause/resume log lines and a double-flood-same-chat test proving the parked mid-chat offset advances instead of resetting. * docs(readme): align the env-table row with pause-and-resume behavior
…res (#224) (#226) * fix(reactions): resume the resweep within the run after a FloodWait expires (#224) Deferring the entire rest of a run on the first FloodWait over-corrected on accounts with small flood buckets: a ~1-minute window turned into hours of cycle latency (one production report covered 2 chats and deferred 498 where the previous behavior covered the full eligible set in one run). The resweep now records the flood expiry and pauses - nothing sleeps, nothing retries, no second-bucket fallback - then resumes within the same run once the server-requested window (plus a 2s margin) has elapsed. Chats reached while cooling down and the window outliving the run still defer to the cycle cursor exactly as before, and after three floods in one run the remainder defers outright since a repeatedly-flooding bucket should be left alone. Adds README sizing guidance for REACTION_RESWEEP_MAX_PER_CHAT on small-bucket accounts. Bumps version to 7.25.1. * docs(readme): resume position is approximate, not exact * docs+tests(review): align narratives with pause-and-resume, guard PII logs and offset advance Panel findings: .env.example and one raw-path comment still described the superseded defer-on-first-flood behavior; the pacing test class docstring likewise. Adds a PII guard test over the new flood/pause/resume log lines and a double-flood-same-chat test proving the parked mid-chat offset advances instead of resetting. * docs(readme): align the env-table row with pause-and-resume behavior
Reopens and completes #224 per the reporter's follow-up on #225.
Problem
The v7.25.0 defer-on-first-FloodWait protected against retry-burn but over-corrected on accounts with small flood buckets (~4 requests vs ~27 on our test instance): one flood deferred the entire remaining run, so a run covered 2 chats and deferred 498 — while the run itself continued for ~6 more minutes with the bucket long refilled (the reported wait was 53s). Net coverage loss versus the old sleep-through-floods behavior.
Fix (the reporter's proposed middle ground, implemented faithfully)
REACTION_RESWEEP_MAX_PER_CHAT(e.g.100) spends ~1 request per chat and lets a single run reach every eligible chat.No new environment variables; the resume margin and flood cap are internal constants.
Testing
2269 tests pass (new: in-run resume after cooldown with a controlled clock, hard-defer after repeated floods, cooldown-skip counting; updated: pause semantics on both request paths, finalize keyed on actual deferral). Live validation on a production instance planned before release.
Summary by CodeRabbit