fix(weixin): propagate asyncio.TimeoutError from _get_updates to prevent zombie connections - #23529
Open
liuhao1024 wants to merge 1 commit into
Open
Conversation
liuhao1024
force-pushed
the
fix/weixin-zombie-connection-23523
branch
from
May 11, 2026 03:36
820ad18 to
9ed9aa7
Compare
…ent zombie connections Previously, _get_updates() caught asyncio.TimeoutError and returned an empty success response (ret=0). This caused the poll loop to reset consecutive_failures to 0 and continue polling indefinitely on a dead network connection, creating a zombie state where the gateway reported 'connected' but no messages could be sent or received. Now, _get_updates() propagates asyncio.TimeoutError, allowing the poll loop's exception handler to treat it as a failure, increment consecutive_failures, log the error, and retry with backoff. Fixes NousResearch#23523
liuhao1024
force-pushed
the
fix/weixin-zombie-connection-23523
branch
from
May 11, 2026 05:31
9ed9aa7 to
c05e973
Compare
teknium1
reviewed
Jul 13, 2026
teknium1
left a comment
Contributor
There was a problem hiding this comment.
Thanks for isolating the timeout-as-success conversion; current main still has that behavior in gateway/platforms/weixin.py:434-435.
Problems
- Propagation alone does not resolve the reported connected-forever state. The timeout would reach the generic handler at
gateway/platforms/weixin.py:1390-1395, which retries and resets the counter but does not call_set_fatal_error, disconnect, or notify the reconnect path._mark_connected()remains active fromgateway/platforms/weixin.py:1295-1296. - The test hunk is stale: current
tests/gateway/test_weixin.py:1194-1207explicitly asserts the old sentinel behavior. It must be replaced, not supplemented, or the salvaged change leaves contradictory tests.
Suggested changes
- After the selected consecutive-failure threshold, transition through the existing fatal/reconnect lifecycle or rebuild the poll session, and add a poll-loop-level regression for that behavior.
- Update the current sentinel test to require
asyncio.TimeoutErrorpropagation.
Automated hermes-sweeper review.
| base_url=base_url, | ||
| endpoint=EP_GET_UPDATES, | ||
| payload={"get_updates_buf": sync_buf}, | ||
| token=token, |
Contributor
There was a problem hiding this comment.
Propagating the timeout is necessary, but _poll_loop currently catches it generically and only retries/resets its counter; it never clears connected state or enters the fatal/reconnect lifecycle. Please add the threshold transition/rebuild path, otherwise the reported health-state zombie remains.
This was referenced Jul 31, 2026
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?
Fixes WeChat gateway zombie connection issue where network drops (WiFi reconnect, macOS sleep/wake) cause the adapter to report "connected" indefinitely but no messages can be sent or received.
Root Cause
_get_updates()caughtasyncio.TimeoutErrorand returned an empty success response (ret=0). This caused the poll loop to:consecutive_failuresto 0weixin.state=connectedforever in/health/detailedThe connection was dead, but the gateway never detected it.
Related Issue
N/A
Type of Change
Changes Made
How to Test
pytest tests/ -q— all tests should passChecklist
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 and workflows — or N/A