fix(telegram): clear send_path_degraded on successful reconnect (#35205) (#54076)

* fix(telegram): clear send_path_degraded on successful reconnect

_send_path_degraded was cleared only in _verify_polling_after_reconnect,
60s after reconnect and only if scheduled. A clean start_polling() reconnect
left the flag stuck True, short-circuiting send() and blocking all outbound
messages until the deferred probe ran (or forever if it never did).

Clear the flag the moment start_polling() succeeds — that is the recovery
signal. The deferred probe remains a defensive re-check that re-enters the
reconnect ladder (re-setting the flag) if it detects a silent wedge.

Fixes #35205.

* docs: add infographic for #35205 telegram send-path fix
This commit is contained in:
Teknium 2026-06-28 01:38:17 -07:00 committed by GitHub
parent 674e16e7c6
commit 2ecb6f7fe6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 64 additions and 6 deletions

View file

@ -1572,6 +1572,17 @@ class TelegramAdapter(BasePlatformAdapter):
self.name, attempt,
)
self._polling_network_error_count = 0
# start_polling() succeeding IS the recovery signal: the long-poll
# connection is live again, so clear the degraded flag immediately
# rather than blocking all outbound sends for the full
# HEARTBEAT_PROBE_DELAY window. The deferred probe below is a
# defensive re-check — if it later detects a silent wedge (PTB
# running=True but consumer task dead) it re-enters the ladder,
# which re-sets _send_path_degraded. Without this clear here, a
# clean reconnect leaves the flag stuck True until the 60s probe
# (or forever, if the probe is never scheduled), blocking the send
# path even though the bot has fully recovered. See #35205.
self._send_path_degraded = False
# start_polling() returning is necessary but not sufficient:
# PTB's Updater can be left in a state where `running` is True
# but the underlying long-poll task is wedged on a stale httpx