fix(e2e,chromedriverproxy): WebSocket/CDP scheme over a TLS-terminating ingress#286
Open
rgarcia wants to merge 2 commits into
Open
fix(e2e,chromedriverproxy): WebSocket/CDP scheme over a TLS-terminating ingress#286rgarcia wants to merge 2 commits into
rgarcia wants to merge 2 commits into
Conversation
…ing ingress
ChromeDriver WebDriver-BiDi over a TLS-terminating ingress (the hypeman
:9224 ingress; serves https/wss) was broken because the BiDi WebSocket
URLs used the wrong scheme. Docker is plaintext (http/ws) so it never
showed there.
Two shared-code fixes:
1. server/e2e/container.go:
- ChromeDriverAddr only stripped "http://", so for an
"https://host:9224" ChromeDriver URL it returned
"https://host:9224" with the scheme still attached.
- ChromeDriverWSURL hardcoded "ws://", producing the malformed
"ws://https://host:9224/session".
Fix: strip any scheme in ChromeDriverAddr; pick ws:// vs wss:// in
ChromeDriverWSURL based on whether the ChromeDriver URL is https.
2. server/lib/chromedriverproxy/proxy.go:
rewriteWebSocketURL kept chromedriver's ws:// scheme, so the
webSocketUrl returned from POST /session was ws://host:9224/... —
unreachable through the TLS ingress. Fix: a new clientWSScheme(r)
helper returns wss when the request arrives with
X-Forwarded-Proto: https (set by the Caddy ingress) or r.TLS != nil,
and rewriteWebSocketURL applies it. Docker (plaintext, no forwarded
proto) keeps ws://. Plus a regression test
TestHandler_PostSession_WSSchemeFromForwardedProto.
Validated in kernel-images-private #237: all 5 TestBidi* (Selenium,
Puppeteer, HTTPSession, Vibium, WebSocket) now pass against the staging
hypeman host over Tailscale.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
Created a monitoring plan for this PR. What this PR does: Fixes WebDriver BiDi connections that were broken when accessed through the Hypeman TLS-terminating ingress — users automating with the BiDi protocol over the secure Intended effect:
Risks:
Status updates will be posted automatically on this PR as monitoring progresses. |
fetchBrowserWebSocketURL hardcoded http:// for the CDP /json/version probe, so it failed against a TLS-terminating CDP ingress (an http:// request hits a TLS listener and errors); plaintext (docker) works. Derive the HTTP scheme from the CDP URL's transport (wss -> https, ws -> http), matching the ChromeDriver accessor scheme handling in this PR. Co-Authored-By: Claude Opus 4.8 (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.
ChromeDriver BiDi and CDP over a TLS-terminating ingress (the hypeman :9224/:9222 ingresses; serve https/wss) were broken because the WebSocket/CDP URLs used the wrong scheme. Docker is plaintext (http/ws) so it never showed there. Validated in kernel-images-private #237: the full e2e suite (incl. all 5 TestBidi* and TestCDPProxyReconnect) now passes against the staging hypeman host over Tailscale.
Fixes
server/e2e/container.go—ChromeDriverAddronly strippedhttp://(returnedhttps://host:9224with scheme attached);ChromeDriverWSURLhardcodedws://(→ malformedws://https://host:9224/session). Now strip any scheme and pickws/wssfrom the ChromeDriver URL's transport.server/lib/chromedriverproxy/proxy.go—rewriteWebSocketURLkept chromedriver'sws://scheme, so thewebSocketUrlfromPOST /sessionwas unreachable through the TLS ingress. NewclientWSScheme(r)returnswsswhenX-Forwarded-Proto: https(Caddy ingress) orr.TLS != nil; docker keepsws. + regression test.server/e2e/e2e_cdp_reconnect_test.go—fetchBrowserWebSocketURLhardcodedhttp://for the CDP/json/versionprobe (fails against the TLS:9222ingress). Derive the scheme from the CDP URL's transport (wss → https).🤖 Generated with Claude Code
Note
Medium Risk
Touches session-creation URL rewriting and shared e2e URL builders used by BiDi/CDP tests; scope is limited to scheme/host correctness with regression tests, but wrong logic would break remote automation connectivity.
Overview
Fixes WebDriver-BiDi and CDP clients failing behind the hypeman TLS ingress (
https/wsson :9224 and :9222) while leaving Docker plaintext (http/ws) behavior unchanged.In
chromedriverproxy,POST /sessionresponses now rewritecapabilities.webSocketUrltowss://when the client reached the proxy via TLS (X-Forwarded-Proto: httpsorr.TLS), via newclientWSSchemeand an updatedrewriteWebSocketURL. A regression test covers the forwarded-proto path.E2e helpers align with the same transport split:
ChromeDriverAddrstrips any URL scheme (not onlyhttp://),ChromeDriverWSURLchooseswsvswssfrom anhttps://ChromeDriver base URL, andfetchBrowserWebSocketURLuseshttpsfor/json/versionwhenCDPURL()iswss://.Reviewed by Cursor Bugbot for commit e4d51ec. Bugbot is set up for automated code reviews on this repo. Configure here.