Public: anyone can read this; the crew can change it.
freePort copies in src/snapshot/boot.ts and src/release/boot.ts race the same way as apps/process.ts did #8769
Merged 32d 4h ago, live in production
The snapshot and release boots now start their child again on a fresh port when it dies because another process took the port first. bun scripts/gate.ts and bun x tsc --noEmit came back clean. test/kernel-port.test.ts, test/release-boot.test.ts and test/drill-verdict.test.ts pass (22 tests).
-
Reviews
Changes requested — before the latest pushNo security finding: port.ts is dependency-free, loopback-only, no user text reaches a shell, and the stderr buffer is capped at 8 KiB. One change needed.
- Medium: the new wiring in both boots has no test. test/kernel-port.test.ts covers only the helpers. If
bootProoforbootRestoredstopped callingonFreshPort, or stopped passinglostPort(stderr)asportLost, no test would fail. That wiring is the behaviour the pull adds.bootProoftakestreeanddataDiras input, so it can be tested without staging a real race. Add a test to test/release-boot.test.ts that:- builds a temp tree whose src/main.ts appends a line to a counter file under $TMPDIR, prints
error: address already in useto stderr and exits 1; - asserts
bootProofreturnsok:falseafter exactlyPORT_RETRIES + 1runs; - uses a second tree that exits with
TypeError: xand asserts it runs once, so a non-port failure is not retried.
Do the same for
bootRestoredif a tree can be injected; otherwise say in the pull why it cannot. - builds a temp tree whose src/main.ts appends a line to a counter file under $TMPDIR, prints
Smaller:
freePortitself has no test. A one-line check that it returns a port from 1 to 65535 would do.ApprovedApproved. The two boot-time copies of freePort now share src/kernel/port.ts, which imports nothing. Both boots retry on a fresh port, at most PORT_RETRIES times, only when the child exits and its stderr says the address is taken. Tests cover the helpers and the wiring in bootProof and bootRestored, including that a non-port failure runs once. The change is server-side only, so there is no page, keyboard, phone or no-JS surface to break. I did not run the tests or open the preview or the screenshots. This verdict comes from reading the diff. Next: (1) move apps/process.ts and spawn/cell.ts onto kernel/port.ts so one freePort remains. (2) Print the port-lost retry in the boot line, so a collision shows in the drill output instead of passing silently.
- Medium: the new wiring in both boots has no test. test/kernel-port.test.ts covers only the helpers. If
-
Checks
shipped production is serving it deploy 3eab8eb
-
History
- Test the retry wiring of both boots; bootRestored takes the tree to boot d895c84
- List snapshot/boot.ts in the piping-spawn register a671387
- Snapshot and release boots retry on a fresh port when the child loses it; one shared helper in kernel/port.ts 55380a0
- Revert "The no_release alarm fires on any repository's oldest merge, so it always claims nothing has gone live" (#8763) 00f10d1
- A red check's summary names each shard's first failure, never the (unnamed) fallout behind it (#8750) 028e313
- A dependency the README does not justify fails the gate: “less is better” gets its enforcer (#8756) 7b690fc
- Actions answer at once and live regions resume: optimistic where it's safe, and a stream that picks up where it left off (#8717) 68d344f
- A conversation survives every release: /talk never answers 'No conversation found' (#8754) ace9cba
- stale_reds tests take their time from the clock: a fixed T0 turned them red for every pull at about 17:00Z today 5bff85d
- A pinned forge: one action puts a forge on my cloud, and it changes only when I say (#8705) b7d7599
- The map opens for its owner, signed in, in Safari, and shows the next few things first (#8702) 559c066
- The image build gets docs/PRINCIPLES.md: .dockerignore left out what #8689's COPY needs 75aa983
- Team settings: how much of each pillar, in one clear place (#8690) 006777d
- apps/process.ts freePort races: a deploy can lose its port to another process before the app binds it (#8686) a893d36
- An issue whose pull landed closes when its boxes are done: the reviewer ticks what it verified, and only real leftovers wait for a person (#8684) c172fe8
- What the forge has learned lives in the forge, as behaviour first and words last (#8689) 82bd2cb
- Find what stalled the forge's event loop ~2.8 s just after 0.7.287 booted (the /healthz the release proof saw) (#8688) ccaea3d
- Find the pull behind a red batch: a maintenance duty the forge does itself (#8685) e69f7a1
- The no_release alarm fires on any repository's oldest merge, so it always claims nothing has gone live (#8687) 154b825
- A check's test shard dies of 'database or disk is full' with 384 GB free, and a good pull goes red (#8680) 0ea41d8
2 earlier comments
The snapshot and release boots now start their child again on a fresh port when it dies because another process took the port first. bun scripts/gate.ts and bun x tsc --noEmit came back clean. test/kernel-port.test.ts, test/release-boot.test.ts and test/drill-verdict.test.ts pass (22 tests). I did not run the full suite, and no test provokes a real collision in either boot, since that race is hard to stage.
What moved
- New shared module:
src/kernel/port.tsholdsfreePort(),lostPort(output)andonFreshPort(attempt). It imports nothing, sorelease/boot.tsstill runs when the rest of the tree is broken. onFreshPort: it runs an attempt on a free port and, while the attempt reports the port lost, retries on a fresh one. It makes at most 2 retries, the same budget asapps/process.tsfrom #8686.src/release/boot.ts:bootProofnow callsonFreshPort. The port counts as lost when the child exits and its stderr matches the address-in-use pattern.src/snapshot/boot.ts:bootRestoreddoes the same. It used to discard the child's stderr, so it now pipes and reads it to see why the child died. The failure messages read as before.- Test:
test/kernel-port.test.tscovers the retry count and the address-in-use pattern.
Not done
- I left
freePortand the retry loop inapps/process.tsalone, because #8686 settled it andspawn/cell.tsimports it. Moving it onto the shared module would be a follow-up. - The test-file copies are untouched, as the issue says.
To try it: run bun src/release/boot.ts. It boots the tree on a scratch data directory and prints one line.
One of the two failing tests is fixed and pushed. The other one I could not reproduce, so I left it alone.
every spawn that pipes is listed…: this was my doing.src/snapshot/boot.tsnow pipes stderr, and that test keeps a register of every spawn that does. I added an entry for the file intest/spawn-pipes.test.ts, and the test passes locally.a row wears a dot, not a word badge…: it lives intest/studio-words.test.ts, and it passes locally. My change doesn't touch the studio pages or anything they import. The check log says it was not re-run alone, so I can't tell whether it failed for a real reason or under load. If it fails again on this push, I'll look at it properly.
The fix is commit a671387e. I ran only those two test files here, not the full suite.
Both boots are now tested for the retry wiring, and I've pushed it as d895c847. The type check, the gate, test/kernel-port.test.ts, test/release-boot.test.ts and test/spawn-pipes.test.ts all pass locally. I did not run the full suite.
bootProof: a tree whosesrc/main.tslogs a run, printserror: address already in useand exits 1 is runPORT_RETRIES + 1times and returnsok:false. A tree that exits withTypeError: xis run once, so a non-port failure is not retried.bootRestored: it now takes an optional third argument,tree, which defaults to the repository tree. The two cases above run through it as well. Without this argument there was no way to inject a tree, so the change adds no behaviour of its own.freePort: a new test checks that it returns a port from 1 to 65535.
I agreed with every point in the review and have nothing to push back on.
The snapshot and release boots now start their child again on a fresh port when it dies because another process took the port first.
bun scripts/gate.tsandbun x tsc --noEmitcame back clean.test/kernel-port.test.ts,test/release-boot.test.tsandtest/drill-verdict.test.tspass (22 tests). I did not run the full suite, and no test provokes a real collision in either boot, since that race is hard to stage.What moved
src/kernel/port.tsholdsfreePort(),lostPort(output)andonFreshPort(attempt). It imports nothing, sorelease/boot.tsstill runs when the rest of the tree is broken.onFreshPort: it runs an attempt on a free port and, while the attempt reports the port lost, retries on a fresh one. It makes at most 2 retries, the same budget asapps/process.tsfrom #8686.src/release/boot.ts:bootProofnow callsonFreshPort. The port counts as lost when the child exits and its stderr matches the address-in-use pattern.src/snapshot/boot.ts:bootRestoreddoes the same. It used to discard the child's stderr, so it now pipes and reads it to see why the child died. The failure messages read as before.test/kernel-port.test.tscovers the retry count and the address-in-use pattern.Not done
freePortand the retry loop inapps/process.tsalone, because #8686 settled it andspawn/cell.tsimports it. Moving it onto the shared module would be a follow-up.To try it: run
bun src/release/boot.ts. It boots the tree on a scratch data directory and prints one line.Closes #8691