fix(telegram): clear send_path_degraded immediately on successful reconnect - #35286
Closed
liuhao1024 wants to merge 1 commit into
Closed
fix(telegram): clear send_path_degraded immediately on successful reconnect#35286liuhao1024 wants to merge 1 commit into
liuhao1024 wants to merge 1 commit into
Conversation
…onnect After a network error, _send_path_degraded was only cleared by the 60-second heartbeat probe in _verify_polling_after_reconnect(). During that window, all outbound send() calls short-circuited as failures, even though polling had already resumed successfully. Clear the flag immediately after start_polling() succeeds. If the send-side httpx pool is also stale, send()'s own retry and error_callback will re-enter the reconnect ladder. Fixes NousResearch#35205
Contributor
|
Automated hermes-sweeper review: this fix is already implemented on current main. Evidence:
Thanks for the original fix and tests here — the same behavior has since landed on main, so this PR is redundant now. |
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?
Clears
_send_path_degradedimmediately after a successfulstart_polling()reconnect, instead of deferring it to the 60-second heartbeat probe. This prevents all outboundsend()calls from being blocked for 60 seconds after the Telegram gateway recovers from a network interruption.Related Issue
Fixes #35205
Type of Change
Changes Made
gateway/platforms/telegram.py: Clear_send_path_degraded = Falseimmediately after successfulstart_polling()in_handle_polling_network_error(), alongside the existing_polling_network_error_count = 0reset. Added comment explaining the rationale.tests/gateway/test_telegram_send_path_health.py: Updatedtest_reconnect_storm_sets_and_heartbeat_clears_flag→test_reconnect_clears_degraded_flag_on_successful_start_pollingto verify the flag is cleared immediately. Addedtest_degraded_flag_stays_true_when_start_polling_failsto verify the flag remainsTruewhen reconnect fails (negative case).How to Test
pytest tests/gateway/test_telegram_send_path_health.py -v— all 4 tests should passpytest tests/gateway/test_telegram_network_reconnect.py -v— all 15 tests should pass (no regressions)Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/ACode Intelligence
gateway/platforms/telegram.pyTelegramAdapter._handle_polling_network_error(called by polling error callback, triggers reconnect ladder)send()retry logic handles stale pool case_verify_polling_after_reconnect()heartbeat probe still runs as secondary safety net;_drain_polling_connections()resets polling pool but not general request pool (documented limitation)