fix: findFallbackPort returns wsPath to fix CDP WebSocket connection#116
Open
yufengzhou46 wants to merge 1 commit into
Open
fix: findFallbackPort returns wsPath to fix CDP WebSocket connection#116yufengzhou46 wants to merge 1 commit into
yufengzhou46 wants to merge 1 commit into
Conversation
When Chrome is started with --remote-debugging-port=9222, the fallback
path in findFallbackPort() detected the open port but returned only a
port number. The CDP proxy then constructed a WebSocket URL like
ws://127.0.0.1:9222/devtools/browser (without UUID), which Chrome
rejects. Chrome requires the full path (e.g. /devtools/browser/<uuid>)
obtained from /json/version.
Changes:
- findFallbackPort() now fetches /json/version and returns {port, wsPath}
- Updated check-deps.mjs and cdp-proxy.mjs callers to use the new struct
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
问题
当 Chrome 通过
--remote-debugging-port=9222启动时,findFallbackPort()能检测到开放端口但只返回端口号。CDP Proxy 随后拼接 WebSocket URL 为ws://127.0.0.1:9222/devtools/browser(缺少 UUID),Chrome 拒绝此连接。Chrome 要求从/json/version获取的完整路径(如/devtools/browser/<uuid>)。同时,新版 Chrome(148+)要求
--remote-debugging-port必须配合--user-data-dir=<非默认目录>使用,这使得 DevToolsActivePort 不在 knownBrowsers() 检查的默认路径中,只能走 fallback 路径,从而使此 bug 必然触发。修复
findFallbackPort()现在 fetch/json/version获取webSocketDebuggerUrl,从中提取 wsPath,以{port, wsPath}结构返回{port, wsPath}返回值,正确拼接 WebSocket URL测试
/health端点返回connected: true/targets、/new、/screenshot、/eval等端点正常/json/version不可用时返回{port, wsPath: null}