Fix CDP proxy reconnect after Chromium restart#189
Merged
sjmiller609 merged 4 commits intomainfrom Mar 26, 2026
Merged
Conversation
…arts When Chromium restarts via supervisorctl, the CDP WebSocket proxy now: 1. Subscribes to upstream URL changes per proxy session, so active connections are proactively closed when the upstream URL changes (forcing clients to reconnect with the fresh URL). 2. If dialing the current upstream URL fails (stale URL from a fast restart cycle), waits up to 5s for a new URL from Subscribe and retries the dial once before giving up. Fixes CUS-109.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
rgarcia
approved these changes
Mar 26, 2026
…-chromium-after-supervisorctl
AbdulRashidReshamwala
added a commit
to reclaimprotocol/popcorn-images
that referenced
this pull request
Mar 27, 2026
Resolved conflicts keeping both Reclaim-specific features and upstream improvements: - config.go: Kept TEE configuration (TEEKUrl, TEETUrl, AttestorUrl) - openapi.yaml: Kept /reclaim/prove endpoint and ReclaimProve* schemas - go.mod: Kept all Reclaim TEE dependencies and updated to latest versions - log.ts: Kept OpenTelemetry logging wrapper around base loggers - proxy.go: Adopted upstream's improved CDP reconnection logic with dialUpstreamWithRetry - Dockerfiles: Hybrid approach - auto-detect ChromeDriver version with override option Key upstream improvements integrated: - CDP proxy reconnection on Chromium restart (kernel#189, kernel#191) - Improved fonts support (kernel#165) - Better error handling in devtools proxy - Updated dependency versions All conflicts resolved, go.sum regenerated, oapi.go regenerated.
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
Fixes CUS-109: CDP proxy doesn't reconnect to Chromium after
supervisorctl restart chromium.The
WebSocketProxyHandlernow wires intoUpstreamManager.Subscribe()to handle Chromium restarts:Proactive teardown — Each proxy session subscribes to upstream URL changes. When Chromium restarts and emits a new DevTools URL, the pump context is cancelled, closing both sides and forcing clients to reconnect with the fresh upstream.
Stale URL retry — If dialing the current upstream fails (race where
supervisorctl restartcycles faster than the tail picks up the new URL), the handler waits up to 5s for a new URL via Subscribe and retries the dial once.Only
server/lib/devtoolsproxy/proxy.gois changed.wsproxy.gois untouched — the handler now callswebsocket.Accept,websocket.Dial, andwsproxy.Pumpdirectly instead of going throughwsproxy.Proxy, giving it the control needed to wire in the subscribe/cancel logic.Testing
Manual CDP Reconnect Validation
Ran a live container from this branch and exercised the CDP proxy on
:9222from the host with raw CDP commands.Test flow
4-5s5ssupervisorctl restart chromiumreturned immediately withstopped/started502on/json/versionfor about6s6safter restart5sObserved behavior
Chrome/146.0.7680.164sum=21, expected title/DOM state)5539bytes)1006/json/versionbriefly returned502sum=21, expected title/DOM state)5210bytes)Result
supervisorctl restart chromium.Note
Medium Risk
Changes WebSocket proxy connection lifecycle and retry behavior around upstream restarts, which could affect stability for all DevTools clients if edge cases or timing assumptions are wrong.
Overview
Fixes CDP proxy behavior when Chromium restarts by wiring
WebSocketProxyHandlerintoUpstreamManager.Subscribe()so active proxy sessions are cancelled when the upstream DevTools URL changes, forcing clients to reconnect.Adds a bounded dial retry path (
dialUpstreamWithRetry) that re-checksmgr.Current()after a failed dial and waits briefly for a new upstream URL, plus a test-only hook (devtoolsProxyTestHook+ env vars) to reliably reproduce the reconnect race.Extends coverage with a new e2e test that restarts Chromium mid-connection and verifies stale sockets close/reject commands and a new session can successfully re-establish and run CDP commands, and adds a unit test for the missed-update retry scenario.
Written by Cursor Bugbot for commit b00410f. This will update automatically on new commits. Configure here.