fix: resolve stale DevToolsActivePort browser UUID via /json/version fallback#35
Open
yusuftok wants to merge 1 commit intopasky:mainfrom
Open
fix: resolve stale DevToolsActivePort browser UUID via /json/version fallback#35yusuftok wants to merge 1 commit intopasky:mainfrom
yusuftok wants to merge 1 commit intopasky:mainfrom
Conversation
…fallback The browser WebSocket UUID stored in DevToolsActivePort can become stale after Chrome restarts or creates a new debug session, causing all CDP commands to fail with "non-101 status code". This is because Chrome writes a new UUID on each debug session but the file may retain the old one. This change makes getWsUrl() async and adds a fallback: before using the file-based UUID, it tries to fetch the live browser WebSocket URL from the /json/version HTTP endpoint (which always returns the current UUID). If the HTTP fetch fails (e.g. port not open), it falls back to the file-based URL as before. All three call sites already use await, so the only caller change is adding await before getWsUrl(). Co-Authored-By: Claude Opus 4.6 (1M context) <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.
Summary
getWsUrl()reads the browser WebSocket UUID fromDevToolsActivePort, but this UUID can go stale after Chrome restarts or creates a new debug session"Received network error or non-101 status code"— includinglisthttp://{host}:{port}/json/version(always returns the active UUID)Root cause
Chrome writes
DevToolsActivePorton startup with a browser-level WebSocket UUID. But when remote debugging is toggled or Chrome's internal debug session refreshes, a new UUID is issued without always updating the file. The HTTP endpoint/json/versionalways reflects the current session.Example of the mismatch:
DevToolsActivePortfilec9af5dba-...(stale)/json/versionendpointf0645277-...(current)Meanwhile, per-page endpoints (
/json/list) work fine — they don't depend on the browser UUID.Changes
getWsUrl()→async getWsUrl()— addsfetch()call to/json/versiongetWsUrl()→await getWsUrl()(all were already inasyncfunctions usingawait)Test plan
cdp.mjs listfailed before fix, works after/json/versionreturns the correct live UUID