fix(proxy): detect stale proxy after browser restart + surface /navigate errors#141
Open
lordk911 wants to merge 1 commit into
Open
fix(proxy): detect stale proxy after browser restart + surface /navigate errors#141lordk911 wants to merge 1 commit into
lordk911 wants to merge 1 commit into
Conversation
…ate errors
A long-running cdp-proxy left over from before Chrome/Edge restarted
passes /health (connected:true) but holds dead sessions: every
Page.navigate silently fails, tabs stay on about:blank, and the
/navigate handler returns an EMPTY response body — so the caller has no
signal to act on. This makes the skill look totally broken ("CDP can do
nothing") for as long as the stale proxy survives.
check-deps reuses any proxy that answers /health, never verifying that
sessions actually work, so the dead proxy is reused indefinitely.
Two fixes:
1. check-deps.mjs — add a functional probe (new about:blank tab -> eval
-> close) in the reuse branch. If it fails, kill the stale proxy and
restart, so a browser restart no longer silently breaks all CDP ops.
2. cdp-proxy.mjs — /navigate now returns HTTP 502 + the CDP error JSON
when Page.navigate yields a {error} (or no result), instead of writing
an empty body that hides the failure.
Repro of the original bug (any machine):
- start Chrome with --remote-debugging-port, run check-deps (proxy up)
- quit & relaunch Chrome (new process, same port)
- run check-deps again -> "proxy: ready" (health still ok)
- /new <url> -> tab stuck on about:blank; /navigate -> empty response
After this patch, step 3 detects the stale proxy and restarts it.
Co-Authored-By: Claude Fable 5 <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.
Problem
When Chrome/Edge is restarted while a
cdp-proxyprocess is already running (very common — users quit/relaunch their browser all the time), the leftover proxy keeps answering/healthwithconnected: true, but its page-level sessions are now dead. The result:Page.navigatesilently fails for every callabout:blank/navigatereturns an empty response body (JSON.stringify(undefined)), so the agent calling it has no signal to act onFrom the outside this looks like "CDP can do nothing / every web task fails" and it persists for as long as the stale proxy survives.
Root cause:
check-depsreuses any proxy that answers/health, never verifying that sessions actually work.Repro
Fix
1.
check-deps.mjs— functional probe in the reuse branchBefore reusing a healthy-looking proxy, run a real
new → eval → closeround-trip on a throwawayabout:blanktab. If it fails, the proxy is stale →pkill -f cdp-proxy.mjsand restart it (the same manual fix the SKILL.md already tells users to do). This makes a browser restart self-healing instead of silently breaking everything.2.
cdp-proxy.mjs—/navigatesurfaces errorsWhen
Page.navigatereturns a CDP{error}(or noresult), return HTTP 502 + the error JSON instead of writing an empty body. Turns an invisible failure into a diagnosable one.Both changes are minimal and additive (happy path behavior is unchanged — verified: navigate still returns full results, the probe passes on a healthy proxy without spurious restarts and leaves
managedTabsat 0).🤖 Generated with Claude Code