fix(telegram): recover when polling updater stops while process stays alive (#55769) - #21
Merged
Conversation
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.
Summary
The Telegram polling watchdog now recovers when PTB's
Updaterstops entirely while the process stays alive — closing the silent-death gap in NousResearch#55769.Root cause:
_probe_pending_updates(the heartbeat's stuck-consumer probe) treatedupdater.running == Falseas "someone else's job" — it reset its counter and returned. Butget_me()on the general request path stays healthy when the long-poll task is simply gone, so neither PTB'serror_callbacknor the connectivity heartbeat ever fires. Result: process alive (systemd green, threads healthy), send path fine, polling dead indefinitely, zero logs.Changes
plugins/platforms/telegram/adapter.py—_probe_pending_updates: detectupdater.running == False(no reconnect in flight) as a dead poller and escalate through the existing_handle_polling_network_errorrecovery ladder after two consecutive probes. Adds_polling_not_running_countdebounce; moves the in-flight-reconnect guard ahead of the updater check so its transientstop()→start_polling()window can't be misread as a dead updater. No new config keys, no new env vars, no new restart machinery.tests/gateway/test_telegram_pending_update_probe.py— replaces the test encoding the old "stopped updater = no-op" assumption with coverage for: single stopped probe doesn't escalate, two consecutive stopped probes trigger recovery, a recovered (running) updater resets the counter, and an in-flight reconnect suppresses escalation.Validation
_probe_pending_updatestestsSalvage of NousResearch#55789 by @PRATHAMESH75 — cherry-picked onto current
main, authorship preserved.Infographic
Mirror-of: NousResearch#55905
NousResearch#55905