fix(gateway): add per-platform connect timeout to prevent blocking (#17242) - #17383
Closed
vominh1919 wants to merge 1 commit into
Closed
fix(gateway): add per-platform connect timeout to prevent blocking (#17242)#17383vominh1919 wants to merge 1 commit into
vominh1919 wants to merge 1 commit into
Conversation
When multiple platforms are configured (e.g., Telegram + Feishu), a slow/hanging platform connect() blocks initialization of all others. Telegram's retry loop (8 attempts × 15s backoff = 120s) can prevent Feishu from ever starting. Wrap each adapter.connect() call in asyncio.wait_for() with a 90s timeout. On timeout, the platform is queued for background reconnection and the next platform starts immediately. Fixes NousResearch#17242
Collaborator
Collaborator
|
Likely duplicate of #13602 — both add per-platform connect timeout. |
Contributor
|
Closed as superseded by #17429 (salvage of #17270). @tmimmanuel's PR was submitted ~5 hours earlier the same day, included tests, and covered the reconnect watcher too — so we went with that one. Thanks for the independent fix; the analysis in your PR body matched the root cause exactly. |
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.
Fixes #17242: Platform initialization failure blocks other platforms
Problem
When multiple messaging platforms are configured (e.g., Telegram + Feishu/Lark), if one platform's
connect()call hangs or takes very long, it blocks initialization of all subsequent platforms.Real-world scenario: Telegram's retry loop (8 attempts × 15s exponential backoff = up to 120s) can prevent Feishu from ever starting — common in regions where Telegram is network-restricted.
Root Cause
The startup loop in
GatewayRunner.start()iterates platforms sequentially and awaits eachadapter.connect()without a timeout:Fix
Wrap each platform's
connect()call inasyncio.wait_for()with a 90-second timeout:On timeout:
_safe_adapter_disconnect()Why 90 seconds?
Testing
ast.parse()Discussed in: #17242