Skip to content

fix: share browser discovery and recover closed CDP handshakes - #166

Open
NBStarry wants to merge 2 commits into
eze-is:mainfrom
NBStarry:fix/shared-proxy-connection
Open

NBStarry wants to merge 2 commits into
eze-is:mainfrom
NBStarry:fix/shared-proxy-connection

Conversation

@NBStarry

@NBStarry NBStarry commented Sep 9, 2026

Copy link
Copy Markdown

当浏览器在 WebSocket 的 open 事件之前关闭调试握手时,connectingPromise 会一直处于 pending,后续 HTTP 请求也随之卡住。另外,连接锁在异步端口发现之后才赋值,并发请求可能各自创建 WebSocket。

此修改让整个发现及握手过程共用一个 Promise,通过 finally 释放连接锁;握手关闭时拒绝等待,并把事件清理绑定到对应的 socket,避免旧连接事件清空新连接。重连时同时清除 session 级端口防护缓存。

验证:新增真实代理子进程回归测试,使用临时浏览器目录、TCP 端口及模拟 WebSocket。首次握手关闭后发起 8 个并发 /targets 请求,断言全部成功且仅建立一次重连。无需访问真实浏览器或个人资料。

  • node --test tests/proxy.test.mjs
  • 原版 2.5.4(33eef84)复现请求超时。
  • 修复版在 Windows 和 macOS 通过。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant