Repository navigation
fix(browser): stop exposing DevTools on a loopback TCP port - #482
Merged
Merged
Conversation
Chrome now runs with --remote-debugging-pipe. The browser supervisor owns the pipe, caches Browser.getVersion, and serves /json/version, one websocket client and POST /close on a 0600 Unix socket in the session temp directory. It publishes the socket in a 0600 cdp-endpoint file. No TCP port exists, so cdpPort leaves records, status and CLI output. The DevTools relay holds the session's one client slot and passes a ws+unix: endpoint to chrome-devtools-mcp. A second relay fails with an "already attached" error. Sessions from an older version still show in status and destroy, but the relay refuses them. Closes #459
The supervisor now opens a browser-target session for each websocket client and runs the client's top-level commands there. Replies and events of that session reach the client without its session id. Root events and events of other sessions stay out. When the client leaves, the supervisor detaches the session, and Chrome ends its tracing, download behavior, auto-attach and contexts made with disposeOnDetach. An attach reply that arrives after its client left is detached. A client can have at most 1024 commands pending, and the commands of a client that leaves are dropped. Ending a relay lease terminates its websocket, so a relay that stopped reading frees the slot at once.
The relay reported an unsafe endpoint file, or one that names a socket outside its session, as "No live browser session". It now says that the session's DevTools endpoint file is unsafe and gives the reason. Session create keeps polling such a file, and its timeout or exit diagnostics now include the reason from the last read.
A client could name a session it never attached, such as one left by an earlier client, and the bridge forwarded the command to Chrome. The bridge now answers with the error Chrome gives for an unknown session. An endpoint file the relay refuses is now reported as one that cannot be used, since the reason is not always its permissions.
A client sees its own browser session as the root session, so a command that names it by id is refused like any other session the client did not attach.
The bridge answers a command for an unknown session itself, so pipe backpressure does not hold those replies back. A client that sends such commands faster than it reads is now closed at the same cap as one with too many commands pending.
A refusal echoes the session id the client sent, so the count cap alone did not bound the bytes it buffers. Chrome's session ids are 32 hex digits, so an id over 128 characters now makes the message invalid.
The refusal cap test relies on the kernel holding fewer refusals than it sends. Sending 50 times the cap keeps that true on hosts with large socket buffers.
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.
A browser session's Chrome served DevTools on a loopback TCP port. Any local process could find and drive it, and after teardown another process could take the freed port.
Chrome now runs with
--remote-debugging-pipe. The browser supervisor owns the pipe and serves it on a 0600 Unix socket, with a 0600 endpoint file. The DevTools relay connects with aws+unix:endpoint and holds the session's one client slot. Each client gets its own browser session, so state it sets up ends when it leaves.Proof: the full suite, real-Chrome tests, and QA journeys through the built CLI. Council review: Sol and Fable ran over 6 rounds. The Kimi seat did not run, because its Go usage limit was reached.
Closes #459
Rollback: revert the merge commit. Browser sessions made by this version then lose the relay and must be recreated. Sessions made by older versions work again.
ss -ltnpfor the session's processes before and after relay use;/json/versionprobed on every port Chrome owns~/.pickforge/investigations/459/qa/d373c23/results.json,.../owned-session/real-chrome-r4.log.../qa/d373c23/results.json,.../owned-session/focused-r4.logPOST /close.../qa/d373c23/status.txt,.../owned-session/real-chrome-r4.logcdpPortremoved from records and output--json, MCP resultscdpPortanywhere.../qa/d373c23/create.json,.../qa/d373c23/status.json.../qa/d373c23/results.json,.../owned-session/focused-r4.logcdpPort.../qa/legacy-b73c45a/disposeOnDetachcontext, root tracing, download behavior, auto-attach, late attach reply, commands for sessions the client did not attach.../worker-fix/probe1.logtoprobe3.log,.../owned-session/focused-r4.log.../owned-session/before-refusals-r5.log,.../owned-session/before-long-id.log,.../owned-session/supervisor-r5-*.log.../worker/supervisor-kill.log--remote-debugging-portand--remote-debugging-pipe.../owned-session/focused-r4.logfull-suite.shon d373c23.../full-r7/Reviews:
Evidence paths are under
~/.pickforge/investigations/459/on the author's machine. Follow-ups found during validation: #480, #481.