Skip to content

fix(weixin): don't swallow asyncio.TimeoutError as success in _get_updates - #34216

Closed
cedricwyh wants to merge 1 commit into
NousResearch:mainfrom
cedricwyh:fix/weixin-zombie-connection
Closed

fix(weixin): don't swallow asyncio.TimeoutError as success in _get_updates#34216
cedricwyh wants to merge 1 commit into
NousResearch:mainfrom
cedricwyh:fix/weixin-zombie-connection

Conversation

@cedricwyh

Copy link
Copy Markdown

Fixes #23523

Problem

_get_updates() catches asyncio.TimeoutError and returns {"ret": 0, "msgs": []} — an empty success that's indistinguishable from a legitimate long-poll with no messages. When the network drops, the poll loop keeps seeing ret=0, resets consecutive_failures, and never detects the zombie connection.

Fix

  • Return {"ret": -999, "errcode": -999, "errmsg": "connection timeout"} on timeout
  • _poll_loop will see non-zero ret, increment consecutive_failures, apply backoff, and trigger reconnection after 3 consecutive failures
  • Also fixed _is_stale_session_ret() to handle empty errmsg without crashing

…dates

The _get_updates() long-poll method catches asyncio.TimeoutError and
returns {"ret": 0, "msgs": []} — an empty success indistinguishable
from a legitimate poll that returned no messages. When the network
drops, the poll loop keeps seeing ret=0, resets consecutive_failures
to 0, and never detects the dead connection. The adapter remains
"connected" forever (zombie state).

Fix: return {"ret": -999, "errcode": -999} on timeout instead,
so _poll_loop treats it as a connectivity failure, increments
consecutive_failures, applies backoff, and can trigger reconnection.

Also fixed _is_stale_session_ret() to handle empty errmsg correctly
instead of crashing with AttributeError.

Fixes NousResearch#23523
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/gateway Gateway runner, session dispatch, delivery platform/wecom WeCom / WeChat Work adapter labels May 29, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Competing with #23529 for #23523 (WeChat zombie connection). This PR returns an error code on timeout; #23529 lets the exception propagate. Also adds _is_stale_session_ret() fix for empty errmsg.

@cedricwyh

Copy link
Copy Markdown
Author

Closing — overlaps with #23529 (same root cause and fix approach). Let that one carry the fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P2 Medium — degraded but workaround exists platform/wecom WeCom / WeChat Work adapter type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: WeChat zombie connection — _get_updates swallows asyncio.TimeoutError as empty success, never detects network drop

2 participants