Skip to main content

Module debugging_port

Module debugging_port 

Source
Expand description

Fixed remote debugging ports for the real browser (issue #101).

A fixed, non-zero --remote-debugging-port is the only CDP transport that leaves navigator.webdriver false without the unsupported --disable-blink-features=AutomationControlled switch: Chromium’s content/child/runtime_features.cc treats --remote-debugging-pipe and --remote-debugging-port=0 as automation, but a specific port as a human attaching a debugger.

The port is reserved by binding 127.0.0.1:0, reading the port the kernel picked and closing the socket. Another process can take the port between that close and Chrome’s bind, so the launcher confirms ownership and retries.

Chrome only writes DevToolsActivePort into the profile for port 0 (see chrome/browser/devtools/remote_debugging_server.cc), so for a fixed port ownership is confirmed from the line Chromium prints to stderr when its DevTools server starts:

DevTools listening on ws://127.0.0.1:<port>/devtools/browser/<id>

When the loopback port is taken Chromium logs bind() failed: Address already in use and falls back to [::1]:<port>; when both fail it logs Cannot start http server for devtools. Either outcome is reported as a race. This mirrors js/src/browser/debugging-port.js.

Structs§

DevToolsListening
The DevTools listening on ... announcement.
DevToolsOutput
What the browser’s stderr says about its DevTools server so far.
DevToolsOutputWatcher
Collects a browser’s stderr so the launcher can confirm which process owns the debugging port.
PortRaceError
The reserved port was taken before the browser could bind it.

Enums§

DevToolsOwnership
Whether the DevTools output proves the port is ours, proves a race, or is not conclusive yet.

Constants§

LOOPBACK_HOST
Interface the reserved port and the DevTools server are bound to.

Functions§

assert_fixed_debugging_port
Validate a caller-supplied debugging port; zero is refused on purpose, because port 0 makes Chrome enable AutomationControlled.
classify_dev_tools_ownership
Decide whether the DevTools output proves that port belongs to our browser, proves a race, or is not conclusive yet.
parse_dev_tools_output
Parse Chromium’s DevTools startup output.
reserve_loopback_port
Reserve a free loopback TCP port for --remote-debugging-port.