Skip to content

fix: avoid cross-loop reuse in weixin direct send#13350

Closed
ifnodoraemon wants to merge 1 commit into
NousResearch:mainfrom
ifnodoraemon:fix/weixin-cross-loop-send
Closed

fix: avoid cross-loop reuse in weixin direct send#13350
ifnodoraemon wants to merge 1 commit into
NousResearch:mainfrom
ifnodoraemon:fix/weixin-cross-loop-send

Conversation

@ifnodoraemon

@ifnodoraemon ifnodoraemon commented Apr 21, 2026

Copy link
Copy Markdown

Summary

  • only reuse the live Weixin adapter session when it belongs to the current event loop
  • fall back to an isolated aiohttp session when direct sends run on a different loop
  • add regression tests covering same-loop reuse and cross-loop fallback

Problem

Weixin direct sends could reuse a live adapter session created on the gateway loop from a different event loop used by the send_message tool path. That produced runtime failures like:

Timeout context manager should be used inside a task

Testing

  • python -m pytest tests/gateway/test_weixin.py -q -o 'addopts='
  • python -m pytest tests/tools/test_send_message_tool.py -q -o 'addopts='

Verification

  • manually restarted the gateway
  • sent a real Weixin validation message successfully after the fix

- only reuse the live adapter session when it belongs to the current event loop
- fall back to an isolated aiohttp session on loop mismatch
- add regression tests for same-loop and cross-loop direct sends
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists platform/wecom WeCom / WeChat Work adapter comp/gateway Gateway runner, session dispatch, delivery duplicate This issue or pull request already exists labels Apr 22, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #13520 — same root cause: cross-event-loop aiohttp session reuse in Weixin direct send path.

1 similar comment
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #13520 — same root cause: cross-event-loop aiohttp session reuse in Weixin direct send path.

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 duplicate This issue or pull request already exists 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.

2 participants