fix(gateway): prevent 100% CPU spin when QQBot WebSocket is closed - #29010
Closed
win847 wants to merge 2 commits into
Closed
fix(gateway): prevent 100% CPU spin when QQBot WebSocket is closed#29010win847 wants to merge 2 commits into
win847 wants to merge 2 commits into
Conversation
When the QQ Bot WebSocket transitions to a closed state (msg.type == WSMsgType.CLOSED), _read_events() raises RuntimeError once, which is caught by the except Exception block. However, _reconnect() temporarily closes the old ws object (self._ws.closed = True) but does not set self._ws = None. On the next loop iteration, _read_events() checks 'if not self._ws' (False, since it's still set) and enters the inner while loop, whose condition 'not self._ws.closed' is immediately False. The function returns normally without raising, causing the outer loop to reset backoff_idx to 0 — resulting in a tight 100% CPU spin loop that never reconnects until the process is killed. Fix: add a 'self._ws.closed' guard at the top of _read_events() so it raises RuntimeError consistently whenever the transport is unusable, forcing the caller's except Exception block to drive proper reconnection with backoff.
ethernet8023
previously approved these changes
May 20, 2026
Collaborator
This was referenced May 20, 2026
Contributor
|
This has been implemented on current main by the merged QQBot reconnect fix. Evidence from this automated hermes-sweeper review:
Thanks for the report and patch. The earlier maintainer note correctly identified this as one of several competing fixes for the same QQBot root cause; main now carries that fix. |
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.
When the QQ Bot WebSocket transitions to a closed state (msg.type == WSMsgType.CLOSED), _read_events() raises RuntimeError once, which is caught by the except Exception block. However, _reconnect() only sets self._ws.closed = True but does not set self._ws = None. On the next loop iteration, _read_events() checks 'if not self._ws' (False, since it is still set) and enters the inner while loop, whose condition 'not self._ws.closed' is immediately False. The function returns normally without raising, causing the outer loop to reset backoff_idx to 0 - resulting in a tight 100% CPU spin loop that never reconnects until the process is killed.
Fix: add a 'self._ws.closed' guard at the top of _read_events() so it raises RuntimeError consistently whenever the transport is unusable, forcing the caller's except Exception block to drive proper reconnection with backoff.