Fix #40691: Reset polling error task guard after successful conflict retry - #40986
Closed
iamlukethedev wants to merge 1 commit into
Closed
Fix #40691: Reset polling error task guard after successful conflict retry#40986iamlukethedev wants to merge 1 commit into
iamlukethedev wants to merge 1 commit into
Conversation
…ul conflict retry Issue NousResearch#40691: Telegram gateway freezes after recovering from a polling conflict (HTTP 409). After successful retry, the gateway appears to be running but stops processing all Telegram messages (both DMs and passive group chat routing). Root Cause: After successfully restarting polling in _handle_polling_conflict, the _polling_error_task guard was not reset to None. This caused the error callback guard (line 1704: if self._polling_error_task and not self._polling_error_task.done()) to silently drop subsequent errors, leaving the gateway frozen but apparently running. Solution: Reset _polling_error_task to None after successful polling restart (line 1131). This allows the error callback to process new errors immediately. The fix is minimal and surgical: - After start_polling() succeeds (line 1121-1125) - Reset the task guard to None (new line: self._polling_error_task = None) - This allows subsequent errors to invoke the callback (guards on line 1704 passes) Added 4 comprehensive tests demonstrating: - Callback task guard allows multiple errors when task is None - Callback task guard blocks concurrent errors (expected behavior) - Conflict recovery pattern includes task guard reset - Callback references remain valid after polling restart All existing conflict tests pass (6 tests).
Contributor
|
Automated hermes-sweeper review: this PR’s target behavior appears implemented on current Evidence:
Thanks for the focused fix and regression-test direction. The underlying bug class has since been handled on main, so this stale PR can be closed as implemented. |
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.
Issue: #40691 — Telegram gateway freezes after polling conflict recovery.
After recovering from a HTTP 409 polling conflict, the gateway remains running but stops processing all Telegram messages (both interactive DMs and passive group chat routing).
Root Cause: After successfully restarting polling in
_handle_polling_conflict, the_polling_error_taskguard was not reset to None. This caused the error callback guard on line 1704 to silently drop subsequent errors, leaving the gateway frozen.Solution: Reset
_polling_error_task = Noneafter successful polling restart. This allows the error callback to process new errors immediately.Changes:
gateway/platforms/telegram.py(line 1131)Test Coverage: