fix(dingtalk): isolate websockets.connect monkey-patch from DingTalk stream SDK#17364
Closed
spike2204 wants to merge 1 commit into
Closed
fix(dingtalk): isolate websockets.connect monkey-patch from DingTalk stream SDK#17364spike2204 wants to merge 1 commit into
spike2204 wants to merge 1 commit into
Conversation
…am SDK The Feishu adapter monkey-patches websockets.connect with an async def wrapper, turning the return value into a coroutine. This breaks the dingtalk-stream SDK's `async with websockets.connect(uri)` call at dingtalk_stream/stream.py:74. Capture the pristine websockets.connect at our import time and install it on dingtalk_stream.stream so the SDK always uses the original regardless of later monkey-patches. - Snapshot _PRISTINE_WEBSOCKETS_CONNECT at module import - _install_dingtalk_websockets_proxy() replaces dingtalk_stream.stream.websockets with a SimpleNamespace holding the original connect + exceptions - Called once during connect() — idempotent, safe no-op when deps missing to #
This was referenced May 13, 2026
Contributor
|
This looks implemented on current main by fixing the root cause at the Feishu wrapper site. Automated hermes-sweeper review evidence:
Thanks for the original narrow DingTalk-side fix; the same bug class has since been addressed at the shared Feishu monkey-patch source. |
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.
Summary
When the DingTalk stream SDK is imported, it monkey-patches
websockets.connectglobally, breaking other WebSocket consumers (Feishu, WeCom, etc.). This PR captures the pristinewebsockets.connectreference before the SDK import and provides_install_dingtalk_websockets_proxy()to restore it.Changes
_PRISTINE_WEBSOCKETS_CONNECTbefore dingtalk-stream import_install_dingtalk_websockets_proxy()that patcheswebsockets.connectto route DingTalk traffic through the SDK's modified version while preserving standard behavior for all other callersconnect()Related
Part of the DingTalk adapter enhancement series — see #12769 for the umbrella PR.