fix(telegram): recover when polling updater stops while process stays alive (#55769) - #55789
Closed
PRATHAMESH75 wants to merge 1 commit into
Closed
Conversation
… alive The polling heartbeat's pending-update probe treated a stopped updater (running=False) as "someone else's job" and silently reset its counter, so a long-poll task that disappears with no reconnect in flight was never recovered. get_me() on the general request path stays healthy, so neither PTB's error_callback nor the connectivity probe ever fires — the gateway keeps running but stops receiving messages indefinitely (NousResearch#55769). Detect the stopped-updater case directly in _probe_pending_updates and feed it into the existing _handle_polling_network_error ladder, debounced over two consecutive probes so a just-starting updater or the brief stop()->start_polling() window of an in-flight reconnect never trips it.
Contributor
|
Merged via PR #55905 (commit e55e9fa on main) — your commit was cherry-picked onto current main with your authorship preserved in git log. Clean, surgical fix that closes the watchdog blind spot exactly at the existing boundary. Thanks @PRATHAMESH75! |
Contributor
This was referenced Aug 3, 2026
Closed
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.
What does this PR do?
After a turn that triggers a background-review, the Telegram gateway can silently stop receiving messages while the process stays alive (systemd green, threads healthy) — no logs, no errors — until manually restarted (#55769).
The adapter already has a polling heartbeat (
_polling_heartbeat_loop→_probe_pending_updates) designed to catch a wedged long-poll consumer. But it only handled the running-but-wedged case. When PTB'sUpdaterstops entirely (running == False) with no reconnect in flight — the long-poll task is simply gone — the probe treated it as "someone else's job", reset its counter, and returned.get_me()on the general request path stays healthy, so neither PTB'serror_callbacknor the connectivity heartbeat ever fires. Result: the watchdog has a blind spot exactly matching the report — process alive, send path fine, polling dead, indefinitely.This fixes the gap at the existing boundary:
_probe_pending_updatesnow detects the stopped-updater case directly and feeds it into the same_handle_polling_network_errorrecovery ladder the wedged-consumer and PTB error paths already use. No new restart machinery, no new config keys, no new env vars.Detection is debounced over two consecutive probes (and skipped while a reconnect is already in flight) so a just-starting updater or the brief
stop()→start_polling()window of an in-flight reconnect never trips a false recovery.Related Issue
Fixes #55769
Type of Change
Changes Made
plugins/platforms/telegram/adapter.py—_probe_pending_updates: detectupdater.running == False(no reconnect in flight) as a dead poller and escalate through_handle_polling_network_errorafter two consecutive probes; added_polling_not_running_countdebounce counter; moved the in-flight-reconnect guard ahead of the updater check so its transient stop/start window can't be misread.tests/gateway/test_telegram_pending_update_probe.py— replaced the test that encoded the old (buggy) "stopped updater = no-op" assumption with coverage for: single stopped probe does not escalate, two consecutive stopped probes trigger recovery, a recovered (running) updater resets the counter, and an in-flight reconnect suppresses escalation.How to Test
Result:
9 tests passed, 0 failed.Checklist
Code
fix(scope):,feat(scope):, etc.)scripts/run_tests.shand they passDocumentation & Housekeeping
docs/, docstrings) — updated_probe_pending_updatesdocstring; otherwise N/Acli-config.yaml.exampleif I added/changed config keys — N/A (no config changes)CONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — N/AScreenshots / Logs
On recovery the heartbeat now logs (previously: total silence):