fix(qqbot): notify gateway via _set_fatal_error when reconnect loop exhausts#14565
Closed
nftpoetrist wants to merge 1 commit into
Closed
fix(qqbot): notify gateway via _set_fatal_error when reconnect loop exhausts#14565nftpoetrist wants to merge 1 commit into
nftpoetrist wants to merge 1 commit into
Conversation
…l_error + _notify_fatal_error
_listen_loop() had three return points where MAX_RECONNECT_ATTEMPTS was
reached but neither _set_fatal_error() nor _notify_fatal_error() was called.
The gateway runner kept the platform marked as connected while the adapter
was dead, and systemd Restart=on-failure never triggered because the
process did not exit.
Adds _set_fatal_error("qq_reconnect_exhausted", ..., retryable=False) and
await self._notify_fatal_error() to all three exhaustion paths — 4008
rate-limit, QQCloseError, and Exception. _set_fatal_error() alone only
writes to the status file; _notify_fatal_error() is required to invoke the
GatewayRunner's _handle_adapter_fatal_error handler, which disconnects the
adapter and stops the gateway. Matches the pattern in the Telegram adapter
(gateway/platforms/telegram.py:366, 460).
Fixes NousResearch#14539
9b2a9f0 to
e38fde9
Compare
12 tasks
This was referenced Apr 25, 2026
Contributor
Author
|
Closing in favour of #19414 which addresses the reconnect loop exhaustion along with four other reconnect bugs. That PR is a more comprehensive fix covering the same root cause. |
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?
`_listen_loop()` in `gateway/platforms/qqbot/adapter.py` has three paths where `MAX_RECONNECT_ATTEMPTS` is reached and the loop exits via `return` — but none of them call `_set_fatal_error()` or `_notify_fatal_error()`. The gateway runner keeps the platform state as the last `_mark_connected()` value (connected), while the adapter is silently dead. Because the gateway process itself does not exit, `systemd Restart=on-failure` never fires.
Three exhaustion paths are affected:
Fix: add `_set_fatal_error("qq_reconnect_exhausted", ..., retryable=False)` followed by `await self._notify_fatal_error()` to all three paths. `_set_fatal_error()` alone only writes to the status file — `_notify_fatal_error()` is required to invoke the GatewayRunner's `_handle_adapter_fatal_error` handler, which disconnects the adapter and triggers `systemd Restart=on-failure`. This matches the pattern already used in the Telegram adapter (`gateway/platforms/telegram.py` lines 366, 460).
Related Issue
Fixes #14539
Type of Change
Changes Made
How to Test
Requires a live QQ Bot setup. Unit tests cover all three paths:
```bash
pytest tests/gateway/test_qqbot.py::TestListenLoopReconnectExhaustion -v
```
All 3 tests pass.
Checklist
Code
Documentation & Housekeeping