Repository navigation
fix(cli): bind-probe 0.0.0.0 and loopback so macOS sees a busy port - #14923
Merged
diegosouzapw merged 1 commit intoSep 29, 2026
Merged
diegosouzapw merged 1 commit into
diegosouzapw merged 1 commit into
Conversation
macOS lets the probe's wildcard bind succeed while another socket holds the port on 0.0.0.0, 127.0.0.1 or ::1, so probePortFree reported a held port as free. Probe those addresses too.
peterbussch
force-pushed
the
fix/cli-loopback-bind-probe
branch
from
September 27, 2026 05:29
ade57ea to
0fad5a1
Compare
diegosouzapw
merged commit Sep 29, 2026
1e6de43
into
diegosouzapw:release/v3.8.51
11 of 16 checks passed
diegosouzapw
pushed a commit
that referenced
this pull request
Sep 29, 2026
serve no longer crashes when discovery returns no pids and the port is free on macOS; merged cleanly beside #14923's bind-probe. Boarded on the release/v3.8.51 tip (3a2678f) with the b3 release-drain batch (26 PRs): typecheck:core and the open-sse typecheck are clean, ESLint is clean on every changed file, migration numbering OK, and the focused tests of the whole board pass 611/611 (51 files). File-size ceiling growth is reconciled in the wave follow-up. Thank you @prabhtheone!
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
On macOS,
probePortFree()says a port is free while another OmniRoute holds it. The probe binds the wildcard address, and macOS allows that bind while another socket listens on the same port at0.0.0.0(the defaultservehost),127.0.0.1or::1. Linux rejects it, so CI stays green, but two tests intests/unit/cli-serve-port-in-use-preflight.test.mjsfail on a Mac.To reproduce (macOS 27.0, Apple M4 Pro, Node 22.23.0,
release/v3.8.51ata58000c768):Cause:
bin/cli/utils/pid.mjs:107-119binds only the wildcard address. On macOS only a bind to the held address itself fails withEADDRINUSE.Fix:
0.0.0.0,127.0.0.1and::1. AnyEADDRINUSEmeans busy.EADDRNOTAVAILon a host without::1), so the probe still never blocks a start it cannot observe (fix(cli): port-in-use guard silently passes when lsof is unavailable (Termux/slim containers) — user gets an EADDRINUSE restart loop instead of the clear message #14518).Related Issues
Note: #14812 fixes the
lsofcrash in #14800 and does not touchprobePortFree. This is the remaining macOS part. The two branches merge cleanly in either order, and the combined test file passes 15/15.Validation
node --import tsx/esm --test tests/unit/cli-serve-port-in-use-preflight.test.mjs: 13 passed on macOS. Before the fix: 10 passed, 3 failed (the new test and the two existing macOS failures).npm run lint: I raneslintandprettier --checkon the changed files only. Both are clean.release/v3.8.51ata58000c768)Tests Added Or Updated
tests/unit/cli-serve-port-in-use-preflight.test.mjsprobePortFree sees a held port when the wildcard bind succeeds (macOS)stubsdeps.netwith macOS bind semantics, so without the fix it fails on Linux CI too.probePortFree treats a missing loopback address as freecovers the fail-open path.Coverage Notes
The two new tests reach every branch of the new loop in
probePortFreewithout opening a socket.Reviewer Notes
servewould bind a different one.findListeningPids()already works that way:lsof -ti :PORTignores the address.