Repository navigation
test(pc-install): stand-in servers' addresses are ports the system gives no other test - #3670
Conversation
…ves no other test ## Why `bun run check fast` on 2026-11-11 failed "starting a stopped server again as it was > starts nothing when its address is taken by a live server, and keeps its log this account's alone" at `expect(await linked.exited).not.toBe(0)`. That restore can exit 0 only by printing `taken`: its log is a link, which the launcher's `O_NOFOLLOW` open refuses with exit 1 every time. The stand-in server never listens, and the server killed just before it does not listen or reopen its log either. So something else was on the address. `freePort()` took a port with port 0 and let it go. The next `port: 0` server can be given that port: another test file's in `check`, an outgoing connection, or this file's own relay in "probes its own PORT, not its registration's port", which takes one with port 0 right after `freePort()`. The restore's probe then finds the address in use and says `taken`. ## What `freePort` in `server/pc-install.test.ts` is `quietPort()` from `scripts/quiet-port.ts` (#3604): a free port outside the range the system hands out for port 0, so no port-0 server or outgoing connection can be on it. Test-only. No assertion, wait or timeout changed, and the product's `taken` probe is unchanged: it is right to refuse an address in use. ## Proof On this PC, the whole file run 8 at a time, beside a process that keeps taking ports with port 0 on 127.0.0.1 and letting them go a few ms later (64 at once), batches of the two alternating: | File | Runs | Failed | |---|---|---| | `main`'s file | 80 | 5 (this test 3x, "probes its own PORT" 1x, "copies a server's program" 1x, all a restore that said `taken`) | | this branch | 80 | 0 | Without that load, `main`'s file failed 1 in 120 runs here ("probes its own PORT", `said` was `taken`). In the last 200 CI runs, no Fast checks job failed in this file.
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
Merge passMerged head
One reviewer: test-only PR (one unit test file). Test-only PR ( It closes a port race in that unit test: the stand-in servers' addresses are now ports the system hands to no other test in the process. The author's runs under port churn: 5 of 80 failed on Left, LOW (Codex, not run), sent to the author's lane: the ports are tracked per process only, so a test file in another process can still take the same one. |
Change
Test-only fix for an intermittent failure in
server/pc-install.test.ts, "starting a stopped server again as it was > starts nothing when its address is taken by a live server, and keeps its log this account's alone" (:1079,expect(await linked.exited).not.toBe(0)), seen in a localbun run check fastrun on a busy host. The same cause can fail two neighbouring tests in that describe block.Cause
The test's
freePort()asked the system for a port (port 0), released it and kept only the number. While the test runs, anotherport: 0listener or an outgoing connection can be given that same number: incheck fast, another test file running in parallel; in the neighbouring test "probes its own PORT…", that test's own relay, which takes a port right afterfreePort(). The restore then finds its address taken and answerstaken, so its log is never written as the test expects.The stand-in server never listens on its port and never reopens its log, so a slow-dying server is not the cause.
Fix
freePortbecomesquietPort()fromscripts/quiet-port.ts, the helper #3604 added for this exact problem: a free port outside the range the system hands out for port 0, so nothing else is given that number. One file, +7/-8. No assertion, wait or timeout changed. The product'stakencheck is unchanged, since refusing an address that is in use is correct.Validation
port: 0listeners on 127.0.0.1 and letting them go, 8 test processes at a time, batches alternating:main's file failed 5 of 80 runs (this test 3×, its two neighbours once each), each time with a restore that saidtaken; the fixed file failed 0 of 80. Without that churn,main's file failed 1 of 120.check fastand the merge gate on a busy host.bun run check fast: pass (16129 pass, 0 fail) on main 1e1e57a.check full. No changelog fragment: test-only.