From 7e7dbd8d01ebc1dab72fb812b4089d3708e870ed Mon Sep 17 00:00:00 2001 From: serxa Date: Tue, 7 Jul 2026 20:51:15 +0000 Subject: [PATCH] Don't drop pending Telegram updates on restart 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. --- nerve/channels/telegram.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nerve/channels/telegram.py b/nerve/channels/telegram.py index cd4dde3..3913281 100644 --- a/nerve/channels/telegram.py +++ b/nerve/channels/telegram.py @@ -332,7 +332,15 @@ async def start(self) -> None: await self._app.initialize() await self._app.start() await self._app.updater.start_polling( - drop_pending_updates=True, + # Do NOT drop updates that queued while we were offline. + # `nerve restart` (and any daemon respawn) goes through this + # startup path; with drop_pending_updates=True, every message + # the user sent during the restart window was silently discarded + # by Telegram and never redelivered — a real "lost message" bug. + # Telegram retains updates ~24h and only advances the offset once + # we fetch them, so False makes a restart pick up the backlog. + # The watchdog _rebuild() path already uses False; keep parity. + drop_pending_updates=False, # Retry initial connection indefinitely — don't give up on # transient network errors during startup bootstrap_retries=-1,