Skip to content

telegram: don't drop pending updates on restart#171

Open
serxa wants to merge 1 commit into
mainfrom
serxa/telegram-no-drop-pending-updates
Open

telegram: don't drop pending updates on restart#171
serxa wants to merge 1 commit into
mainfrom
serxa/telegram-no-drop-pending-updates

Conversation

@serxa

@serxa serxa commented Jul 7, 2026

Copy link
Copy Markdown
Member

Problem

The Telegram bot's startup path — taken by every nerve restart and daemon respawn — calls Updater.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 uses drop_pending_updates=False; only the startup path had True.

Fix

Set drop_pending_updates=False on 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 getUpdates and 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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant