fix(infra): probe 127.0.0.1 in ensurePortAvailable to detect IPv4-only occupants#94394
Conversation
|
Codex review: found issues before merge. Reviewed June 18, 2026, 9:13 AM ET / 13:13 UTC. Summary Reproducibility: yes. Current main and v2026.6.8 still use a hostless port probe before managed Chrome launch, and the PR body plus maintainer comment provide terminal proof for the IPv4-loopback occupant path. Review metrics: 3 noteworthy metrics.
Stored data model Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Scrub or rebuild the branch so one canonical PR lands only the port-preflight fix and focused tests, with explicit maintainer acceptance of the SDK-visible helper shape or a Browser-private alternative. Do we have a high-confidence way to reproduce the issue? Yes. Current main and v2026.6.8 still use a hostless port probe before managed Chrome launch, and the PR body plus maintainer comment provide terminal proof for the IPv4-loopback occupant path. Is this the best way to solve the issue? No as currently submitted. The focused port fix is a maintainable direction, but the branch must drop unrelated dependency/workflow/repo-wide churn and get an explicit SDK API-shape decision before it is the best merge path. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 712e45daf137. Label changesLabel changes:
Label justifications:
Evidence reviewedSecurity concerns:
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
Land-ready verification and landing for
No known proof gap for the changed Chrome CDP collision path. |
590ba12 to
65bbefd
Compare
|
Merged via squash.
Thanks @Pandah97! |
Summary
ensurePortAvailable()uses a barenet.listen({ port })with nohostparameter. On dual-stack machines, a host-less listener binds to the IPv6 wildcard::and does not detect an IPv4-only occupant of the same port. Chrome binds its CDP debug port on127.0.0.1, so when an IPv4-only process occupies the port, the pre-flight reports it as free, Chrome then fails withbind() failed: Address already in use, and the user sees a misleadingHTTP 401error.Fix: Add
host: "127.0.0.1"toensurePortAvailable's probe so it detects IPv4-only occupants on the loopback interface — matching the address family Chrome actually uses.Changes
src/infra/ports.ts:42tryListenOnPort({ port })→tryListenOnPort({ port, host: "127.0.0.1" })Real behavior proof
Behavior addressed: When Chrome (or any IPv4-only process) occupies a port on
127.0.0.1, the pre-flightensurePortAvailable()call returns "free" because host-lessnet.listenbinds::(IPv6 wildcard), which does not conflict with an IPv4-only bind. Chrome then fails with EADDRINUSE, producing a misleading error chain.Real environment tested: Linux x86_64 (kernel 4.19.112) with dual-stack IPv6 enabled (default
net.ipv6.bindv6only=0). Node.jsnet.listenbehavior confirmed: host-less listen binds::on dual-stack kernels.Exact steps or command run after this patch:
After-fix evidence:
All 13 port tests pass. The change adds
host: "127.0.0.1"to the probe.Observed result after the fix:
ensurePortAvailable()now matches the address family Chrome actually binds. Annc -l 127.0.0.1 18800occupant is correctly detected:ensurePortAvailable(18800)returnsfree(false negative — host-less probe binds::)ensurePortAvailable(18800)throwsPortInUseError(correct — probe binds127.0.0.1)What was not tested: End-to-end Chrome CDP port occupation in a real Gateway sandbox session (requires live Chrome process attached to the gateway port allocation flow). The unit-level probe behavior is the authoritative validation point since
ensurePortAvailableis a single-responsibility function whose only job is to detect port occupancy.Test results
Risk checklist
Did user-visible behavior change? (
Yes)HTTP 401when the port is occupiedDid config, environment, or migration behavior change? (
No)Did security, auth, secrets, network, or tool execution behavior change? (
No)host: "127.0.0.1"restricts the probe to IPv4 loopback, strictly narrowing the scopeWhat is the highest-risk area?
127.0.0.1is part of the POSIX standard loopback range)How is that risk mitigated?
13 tests) validates the probe in the normal casenet.listenthrows a predictable error thathandlePortErroralready handles gracefullyCurrent review state
What is the next action?
What is still waiting on author, maintainer, CI, or external proof?
Closes #94379