Skip to content

Fix CDP proxy reconnect after Chromium restart#189

Draft
sjmiller609 wants to merge 1 commit intomainfrom
steven/cus-109-cdp-proxy-doesnt-reconnect-to-chromium-after-supervisorctl
Draft

Fix CDP proxy reconnect after Chromium restart#189
sjmiller609 wants to merge 1 commit intomainfrom
steven/cus-109-cdp-proxy-doesnt-reconnect-to-chromium-after-supervisorctl

Conversation

@sjmiller609
Copy link
Contributor

Summary

Fixes CUS-109: CDP proxy doesn't reconnect to Chromium after supervisorctl restart chromium.

The WebSocketProxyHandler now wires into UpstreamManager.Subscribe() to handle Chromium restarts:

  1. 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.

  2. Stale URL retry — If dialing the current upstream fails (race where supervisorctl restart cycles 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.go is changed. wsproxy.go is untouched — the handler now calls websocket.Accept, websocket.Dial, and wsproxy.Pump directly instead of going through wsproxy.Proxy, giving it the control needed to wire in the subscribe/cancel logic.

Test plan

  • Deploy to a test VM, connect a CDP client, run supervisorctl restart chromium, verify the client gets disconnected and can immediately reconnect
  • Verify that during a fast restart cycle (stale URL), new CDP connections succeed after the brief retry wait
  • Verify normal CDP proxying still works without Chromium restarts

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant