Repository navigation
Conversation
CLI test fixtures started their fake daemon with listen(0), a wildcard
("::") bind, while the client under test reached it at 127.0.0.1:<port>
(the daemon URL default, or an explicit 127.0.0.1 URL). On macOS a
wildcard bind does not reserve 127.0.0.1:<port>, so a concurrent
127.0.0.1:0 listener in another test file can bind the same port number
and answer instead. status.test.ts then timed out on "reports a snapshot
taken two minutes ago as 2m ago" with an unhandled DaemonResponseError
(HTTP 404).
Bind those 75 fixtures (54 files) to 127.0.0.1 so the kernel refuses a
second loopback bind. client.test.ts keeps its wildcard bind: its client
uses localhost, not 127.0.0.1.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
What a user gets
No product change. The CLI test suite stops flaking when two test files pick the same ephemeral port. Most CLI fixtures started their fake daemon with
server.listen(0), a wildcard (::) bind, while the client under test reached it at127.0.0.1:<port>(the default daemon URL from a state file withouthost, or an explicit127.0.0.1URL). On macOS a wildcard bind does not reserve127.0.0.1:<port>, so a concurrentlisten(0, "127.0.0.1")in another test file can take the same port and answer instead. Observed:status.test.ts > snapshot age under TZ=America/Los_Angeles > reports a snapshot taken two minutes ago as 2m agotimed out at 20000ms with an unhandledDaemonResponseError: The daemon returned an unreadable response (HTTP 404).This binds those 75 fixtures (54 files under
packages/cli/test) to127.0.0.1, so the kernel refuses a second loopback bind on that port. It is the same fix #3891 made for the pair-client target inhosts-add-pair-routes.test.ts; that file is left to #3891.How you verified it
On this branch's commit, macOS, Node 22:
listen(0...), binds a second server on127.0.0.1:<same port>answering 404, and holds the original listen callback until that bind succeeds or fails.status.test.ts),-t "snapshot age": all threereports a snapshot taken two minutes ago as 2m agocases fail with the sameDaemonResponseError (HTTP 404). The second bind succeeded against::every time.status.test.ts28/28 pass. All 15 second binds are refused withEADDRINUSE..listen(orserve(. The second bind succeeded in only two places, both left unchanged:client.test.ts, whose client useslocalhost, andhost-ipv6-status.test.ts, which binds::1. The 11 tests that failed in that run all need the built CLI (dist/), which I did not build.npm run build, the fullnpm test,npm run lint.Anything you were unsure about
preflight.test.tsand one case inup.test.tsuselisten(0)as a port-in-use blocker. The preflight probe connects to127.0.0.1, so I bound those blockers to the address they are probed on.client.test.tsand the daemon'stcp-readiness-native.test.tsalone. The first useslocalhost; the second binds the host under test explicitly.test/changes.If this is security-related
Not security-related.
CHANGELOG.mdedit🤖 Generated with Claude Code
Summary by CodeRabbit