fix(weixin): avoid cross-loop live adapter reuse in direct send#13361
fix(weixin): avoid cross-loop live adapter reuse in direct send#13361dso2ng wants to merge 1 commit into
Conversation
|
Maintainer context: this PR is intended to address the live Weixin cron / one-shot delivery failure pattern that surfaces as:
Local verification is complete:
The change is intentionally narrow:
If fork workflows are still blocked in |
|
@kshitijk4poor @teknium1 friendly ping on this Weixin fix: it is narrowly scoped to the cross-event-loop direct-send failure pattern ( If fork workflows still need maintainer approval to run, approving/running them in the GitHub UI should let CI start and make the remaining signal much clearer. |
630034a to
056f9d5
Compare
|
Maintainer note: I updated this PR to use my GitHub noreply commit email, so the attribution issue should be fixed. The current checks are action_required with zero jobs started, so it looks like fork-PR workflow approval is blocking CI from actually running. Once approved/run in the GitHub UI, I can follow up on any real failures. |
|
Thanks for the contribution, @dso2ng! Closing this as a duplicate of #13350 (by @ifnodoraemon), which targets the same fix/feature. We're consolidating on that PR for review. If you want to help push it over the line, please jump in there — or if you think your approach is better for a specific reason that isn't covered in the other PR, let us know and we can reopen. |
Summary
send_weixin_direct()from reusing a live Weixin adapter across event loopsaiohttp.ClientSessionWhy
Cron delivery and other one-shot messaging paths can call
send_weixin_direct()outside the gateway's main event loop. Reusing a live Weixin adapter from those paths can cross event-loop boundaries and trigger aiohttp task/timeout errors instead of delivering the message.Root cause
send_weixin_direct()preferred_LIVE_ADAPTERS[resolved_token]whenever a live adapter and_send_sessionexisted. That live adapter's aiohttp session is created inside the gateway event loop, but one-shot delivery helpers may execute from another loop or thread. Reusing the live adapter directly in that context can raise errors such as:Timeout context manager should be used inside a taskBehavior before
Behavior after
send_weixin_direct()no longer reuses a live adapter across loopsHow to test
source venv/bin/activate && python -m pytest tests/gateway/test_weixin.py -qTimeout context manager should be used inside a taskPlatforms tested
Notes