fix(gateway): connect all messaging platforms concurrently with per-platform timeout - #13602
fix(gateway): connect all messaging platforms concurrently with per-platform timeout#13602IamBaoMouMou wants to merge 1 commit into
Conversation
…latform timeout Problem: Gateway connected to messaging platforms sequentially. If one platform (e.g. Discord in China, blocked by GFW) times out (~60s), ALL other platforms (Telegram, DingTalk, WeChat) were blocked from starting, causing cron jobs to fail silently. Fix: Connect all platforms concurrently via asyncio.gather(), each with an independent 30s timeout. A slow or failed platform no longer blocks other platforms that can connect instantly. - Add _PLATFORM_CONNECT_TIMEOUT (30s) per-platform connection timeout - Phase 1: create all adapters synchronously (fast) - Phase 2: connect all platforms concurrently with asyncio.gather() - Phase 3: process results — successful platforms go live immediately, failed/timeout platforms enter background reconnect queue Fixes: cron jobs failing when Discord is unreachable in China.
|
Thanks for targeting a real remaining startup bottleneck. Current Problems
Suggested changes
Automated hermes-sweeper review. |
|
Closing as superseded: parallel platform connects at gateway startup landed on main via #86673 (salvage of #83809), which keeps the existing per-platform timeout path and error handling and adds a capped Telegram cold-start budget. This PR pioneered the concurrent-startup idea back in April — thank you — but it is 4 months stale against a heavily rewritten startup loop (per-platform runtime status, multiplexing, abort-aware shutdown fencing) and the merged implementation covers its goal. |
Problem
Gateway connected to messaging platforms sequentially. If one platform (e.g. Discord in China, blocked by GFW) times out (~60s), all other platforms (Telegram, DingTalk, WeChat) were blocked from starting, causing cron jobs to fail silently.
Fix
Connect all platforms concurrently via
asyncio.gather(), each with an independent 30s timeout.Three phases:
asyncio.wait_for(adapter.connect(), timeout=30.0)Why this is safe
asyncio.gather(return_exceptions=True)pattern ensures one platform timeout does not cancel others_failed_platformsreconnect queueasyncio.TimeoutErrorpath calls_safe_adapter_disconnect()for clean resource cleanupTesting