fix(feishu): avoid global websockets monkey-patching to prevent DingTalk conflict#15986
Conversation
…alk conflict The Feishu platform adapter was monkey-patching websockets.connect globally, which broke other platforms (e.g., DingTalk) that also use websockets. Changes: - Create a local copy of the websockets module for Feishu WS client - Apply connection overrides only on the local copy - Restore the original module reference in finally block This allows Feishu and DingTalk (and potentially other platforms) to coexist without interfering with each other's websocket connections.
|
The intent of this PR (stop globally monkey-patching Closing this PR so it doesn't land as-is. If you want to pursue the fix, the cleaner shape is: use |
Problem
The Feishu platform adapter was monkey-patching
websockets.connectglobally in_run_official_feishu_ws_client. This caused issues when running multiple platforms simultaneously — specifically, DingTalk (which also uses websockets) would break because its connection logic was being overridden by Feishu's custom overrides.Solution
Instead of patching the global
websocketsmodule, create a local module copy for the Feishu WS client:types.ModuleTypeto create a localwebsocketsmodule copy_connect_with_overridesonly on the local copyws_client_module.websocketsChanges
gateway/platforms/feishu.py: Modified_run_official_feishu_ws_clientto use local module copy instead of global monkey-patchingTesting
Impact
This is a minimal, non-breaking change that enables multi-platform deployments where Feishu and DingTalk (or other websocket-using platforms) need to coexist.