fix(anneng): bound CDP websocket recv with 15s socket timeout

websocket.create_connection had no timeout, so a hung Runtime.evaluate
(Electron business tab not replying) blocked ws.recv() indefinitely — the
export-poll's 300s deadline and with_retry could never fire (observed as a
~22min hang on an 安能 expected download). A 15s socket timeout lets recv
raise WebSocketTimeoutException so wait_until/with_retry can fail and retry.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Misaka_Company
2026-07-24 12:22:22 +08:00
parent 615661c275
commit 0111734e9c

View File

@@ -112,7 +112,10 @@ class CDP:
"""绑定到单个页面目标的同步 CDP 客户端。""" """绑定到单个页面目标的同步 CDP 客户端。"""
def __init__(self, ws_url): def __init__(self, ws_url):
self.ws = websocket.create_connection(ws_url) # socket 级超时Electron 业务 tab 偶发不回包时recv 最多卡 15s 即抛
# WebSocketTimeoutException让上层 wait_until/with_retry 能失败→重试,
# 而不是无限阻塞(曾导致安能下载卡死 ~22 分钟、轮询 300s 截止也无法触发)。
self.ws = websocket.create_connection(ws_url, timeout=15)
self._id = 0 self._id = 0
self.call("Runtime.enable") self.call("Runtime.enable")