telegram: don't drop pending updates on restart#171
Open
serxa wants to merge 1 commit into
Open
Conversation
The startup path (every `nerve restart` / daemon respawn goes through it) called Updater.start_polling(drop_pending_updates=True), telling Telegram to discard every update queued while the bot was offline. Any message a user sent during the restart window was silently dropped and never redelivered. Set drop_pending_updates=False so a restart replays the backlog Telegram retains (~24h; the read offset only advances once we fetch them). This matches the watchdog _rebuild() path, which already uses False.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The Telegram bot's startup path — taken by every
nerve restartand daemon respawn — callsUpdater.start_polling(drop_pending_updates=True). That tells Telegram to discard all updates queued while the bot was offline, so any message a user sends during the restart window is silently dropped and never redelivered.The watchdog
_rebuild()path already usesdrop_pending_updates=False; only the startup path hadTrue.Fix
Set
drop_pending_updates=Falseon the startup path. Telegram retains updates (~24h) and only advances the read offset once we fetch them, so a restart now replays the backlog instead of dropping it. Brings the startup path into parity with_rebuild().Note
A narrow gap remains: python-telegram-bot holds the fetch offset in memory, so a crash between
getUpdatesand handler dispatch could still drop an in-flight update. Closing that fully would need a durable inbox; this PR fixes the common restart-window loss.Testing
No Telegram/channel tests exist in the suite; the change is a single kwarg flip. Relying on CI.