fix: 从 HTTP API 动态获取 Chrome WebSocket URL#61
Open
hiweiweiwei-bot wants to merge 2 commits intoeze-is:mainfrom
Open
fix: 从 HTTP API 动态获取 Chrome WebSocket URL#61hiweiweiwei-bot wants to merge 2 commits intoeze-is:mainfrom
hiweiweiwei-bot wants to merge 2 commits intoeze-is:mainfrom
Conversation
改用 /json/version HTTP API 获取最新 wsUrl,避免 Chrome 重启后 DevToolsActivePort 文件中的 wsPath 过期导致连接失败;原有 wsPath 回退逻辑保留。 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Owner
|
我想确认问一下,你这边使用chrome的场景是直接使用用户自己在用的这一个浏览器实例呢,还是通过命令行调用了headless chrome? |
Author
|
直接使用用户自己正在运行的 Chrome 实例(非 headless),通过 这也是这个 fix 的核心场景:用户浏览器重启后,DevToolsActivePort 文件还是旧的 WebSocket URL,所以改成优先从 |
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 重启后,
DevToolsActivePort文件中缓存的wsPath会过期,导致 CDP Proxy 连接失败,需要手动重启 Proxy。改动
将
getWebSocketUrl()改为异步函数,优先通过/json/versionHTTP API 获取最新的webSocketDebuggerUrl:ws://[::1]→ws://127.0.0.1地址格式差异测试
Chrome 重启后无需重启 CDP Proxy,自动重连成功。
🤖 Generated with Claude Code