Repository navigation
Add Chrome profile and debugging-port options to ts dev proxy --launch - #1728
Draft
ChristianPavilonis wants to merge 8 commits into
Draft
ChristianPavilonis wants to merge 8 commits into
ChristianPavilonis wants to merge 8 commits into
Conversation
Parse --chrome-user-data-dir and --chrome-debug-port, require chrome in --launch, make the directory absolute, reject default Chrome and Chromium user data directories, and reject a debug port equal to --listen. Box ProxyArgs in DevCommand to keep the enum variants balanced. Refs #1724
With --chrome-user-data-dir, Chrome uses that directory and the proxy never deletes it. With --chrome-debug-port, Chrome gets --remote-debugging-port and the proxy waits for DevToolsActivePort, then prints the http and ws endpoints. A preflight runs before CA loading and the bind. It creates the user data directory with mode 0700, refuses a profile another Chrome holds by reading SingletonLock, removes a stale DevToolsActivePort, and checks that a non-zero debug port is free. With either option set, every Chrome launch failure stops the proxy and kills a Chrome it started. Without them, launch failures stay warnings. Refs #1724
The manual Linux proof launches real, headed Chrome through ts dev proxy --launch chrome with a kept user data directory and port 0, using a disposable HOME, CA and NSS database. It checks the DevTools endpoint and CDP attach, the in-use refusal, cookie persistence across a relaunch, and recovery from a stale lock after SIGKILL. Refs #1724
Add the guide section on keeping a Chrome profile and attaching automation, with the debugging-port warning, update the Chrome browser details and troubleshooting rows, describe the Node launch proof, and add a changelog entry. Include the design spec and implementation plan. Refs #1724
Chrome writes DevToolsActivePort only for --remote-debugging-port=0, so a fixed --chrome-debug-port never finished startup. Read the spawned Chrome's own "DevTools listening on" stderr line instead, copying every line through to the proxy's stderr. With only --chrome-user-data-dir, wait for SingletonLock to name the spawned pid, so a Chrome that exits at startup or hands its URL to another instance is reported. Re-check the user data directory against the default directories after creating it, so a path such as not-yet/../.config/google-chrome cannot reach the real profile, and launch with that canonical path. Watch for Ctrl-C while the launch waits, cancel the wait, kill the Chrome still being waited on, and run the usual interrupt cleanup. Build the missing-launcher messages from CHROME_LAUNCHERS, move trait imports to module scope, and follow the test message conventions. Refs #1724
Issue the fixture cookie only during the first launch and require the first request after the relaunch to send it. Relaunch on a fixed debug port, and check that Chrome outlives the proxy and still answers CDP. Refs #1724
This branch has not been deployed
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
--chrome-user-data-dir <DIR>and--chrome-debug-port <PORT>tots dev proxy --launch chrome. A kept user data directory survives Chrome exit, so a bot challenge solved once in that profile carries over to the next launch. The debugging port lets PlaywrightconnectOverCDPor the Chrome DevTools MCP attach to the proxied browser over loopback.--launch chromebehaves exactly as before.Two deliberate differences from the issue:
--chrome-user-data-dir, not--chrome-profile. In Chrome, a profile is a subdirectory such asDefaultinside the user data directory, selected with--profile-directory; Playwright and the DevTools MCP both call the whole directoryuserDataDir.Changes
crates/trusted-server-cli/src/commands/dev/proxy/mod.rscrates/trusted-server-cli/src/commands/dev/proxy/config.rsChromeLaunchOptions. Rejects either option withoutchromein--launch, makes the directory absolute, rejects default Chrome and Chromium user data directories, and rejects a debug port equal to--listen.crates/trusted-server-cli/src/commands/dev/proxy/browser.rs0700, re-checks its real path against the defaults, refuses a profile another Chrome holds by readingSingletonLock, and checks the port. Launch: adds--remote-debugging-port, waits for the spawned Chrome'sDevTools listening onstderr line (copied through to the proxy's stderr) or, with only a kept directory, forSingletonLockto name the spawned pid. Kills that Chrome on failure.crates/trusted-server-cli/src/commands/dev/mod.rsProxyArgsfor Clippy'slarge_enum_variant, asCommand::Auditalready does.Cargo.toml,crates/trusted-server-cli/Cargo.toml,Cargo.lockrustix(process,system) as a direct dependency for the hostname and pid liveness checks withoutunsafe. It was already in the tree throughtempfileandgix; the lockfile only gains the dependency edge.crates/trusted-server-cli/tests/proxy_cli.rsgoogle-chromescript for fixed-port readiness, early exit, lock-based readiness and Ctrl-C during the wait.scripts/test-linux-dev-proxy-launch.mjsdocs/guide/ts-dev-proxy.mdCHANGELOG.mddocs/superpowers/specs/…-design.md,docs/superpowers/plans/…mdCloses
Closes #1724
Follow-up filed from this work: #1725, temporary browser profiles leak when the proxy exits before the browser. That predates this change and is not fixed here.
Spec
Spec:
docs/superpowers/specs/2026-12-02-1724-dev-proxy-chrome-profile-design.mdThe review log has one independent round so far. It found that Chrome writes
DevToolsActivePortonly for port0, which the first design relied on, plus five other defects; all are fixed. A second review round is still needed before this leaves draft.Test plan
cargo test-fastly && cargo test-axum(not run; this change is CLI-only)cargo clippy-fastly && cargo clippy-axum(not run; CLI-only)cargo fmt --all -- --checkcd crates/trusted-server-js/lib && npx vitest run(no JS changes)cd crates/trusted-server-js/lib && npm run format(no JS changes)cd docs && npm run format(changed Markdown checked with Prettier 3.8.1 anddocs/.prettierrc; the VitePress build was not run)cargo build --package trusted-server-adapter-fastly --release --target wasm32-wasip1(not run; CLI-only)fastly compute serve(not applicable)./scripts/test-cli.shon Linux x86_64: 804 lib tests and all integration tests pass, including 9 inproxy_cli.cargo clippy-cliand host-targetcargo clippy --package trusted-server-cli --all-targets --all-features -- -D warnings.ts dev lint domains --changed-vs origin/mainandgit diff --check origin/main.node scripts/test-linux-dev-proxy-launch.mjspassed on Chromium 155.0.8059.84 and Google Chrome 158.0.8127.36: DevTools endpoint and CDP attach, in-use refusal without a new window, cookie persistence across a relaunch on a fixed port, Chrome outliving the proxy, and recovery from a stale lock after SIGKILL.connectOverCDPand Chrome DevTools MCP attach.Checklist
unwrap()in production code — useexpect("should ...")logmacros (notprintln!)