fix(qqbot): check ws.closed in _read_events to prevent idle loop on reconnect failure - #25070
Closed
bighamx wants to merge 1 commit into
Closed
fix(qqbot): check ws.closed in _read_events to prevent idle loop on reconnect failure#25070bighamx wants to merge 1 commit into
bighamx wants to merge 1 commit into
Conversation
…econnect failure When a WebSocket reconnect fails, the old _ws object remains but is closed. _read_events() only checked 'if not self._ws', so a closed-but-not-None WebSocket caused the method to return immediately without error. The event loop then reset the backoff counter, entering an infinite idle loop with no further reconnection attempts. Fix: add 'or self._ws.closed' check so a closed WebSocket raises RuntimeError and triggers proper reconnect logic.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a QQ Bot reconnect edge case where a failed reconnection could leave a non-None but closed WebSocket object in self._ws, causing _read_events() to return immediately and the outer loop to reset backoff and idle indefinitely.
Changes:
- Treat a closed WebSocket the same as “not connected” in
_read_events()by checkingself._ws.closed. - Ensure
_read_events()raisesRuntimeError("WebSocket not connected")when the WS is closed, so the existing reconnect/backoff logic is engaged.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Collaborator
This was referenced May 23, 2026
Closed
Contributor
|
Automated hermes-sweeper review: this QQBot reconnect fix is already implemented on current Evidence:
Thanks for the focused report and patch. The current main branch has the same behavior covered by regression tests. |
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.
Bug
QQ Bot WebSocket reconnect enters an infinite idle loop after a failed reconnection.
Root Cause
When a WebSocket reconnect fails (e.g. transient network error getting the gateway URL), the old
_wsobject remains but is closed._read_events()at line 631 only checkedif not self._ws:, so a closed-but-not-None WebSocket passed the guard. Thewhileloop conditionnot self._ws.closedevaluated to False immediately, causing_read_events()to return successfully. The event loop then reset the backoff counter (backoff_idx = 0), entering an infinite idle loop with no further reconnection attempts and no log output.Fix
Add
self._ws.closedcheck in the guard:This causes
_read_events()to raiseRuntimeError("WebSocket not connected")when the WS is closed, properly triggering the reconnect logic in the event loop.Observed Behavior
Reconnect failed: Failed to get QQ Bot gateway URL:(empty error, transient)After Fix
The closed WebSocket triggers
RuntimeError, the event loop catches it and uses the existing backoff logic to retry reconnection.