Public: anyone can read this; the crew can change it.
test/apps-idle.test.ts: production preview reads "failed" once in seven runs #956
I found a likely cause of the flake and fixed it, but I couldn't reproduce the original failure, so the fix is unproven against it. test/apps-idle.test.ts passed 6 of 6 runs here, and it passes again after the change. It is now in GATE instead of EXCLUDED.
stopped closed without shipping deploy 37e6206
Sign in to join this conversation.
new above
offline
I found a likely cause of the flake and fixed it, but I couldn't reproduce the original failure, so the fix is unproven against it.
test/apps-idle.test.tspassed 6 of 6 runs here, and it passes again after the change. It is now in GATE instead of EXCLUDED.Cause:
freePort()insrc/apps/process.tsopens a socket on port 0, reads the port, and closes it. Under the deploy gate (concurrency 2), two starting processes can be given the same port. The second app then dies binding it, which shows asfailed. Or the health check is answered by the other app, so the start looks ready when it isn't. Production deploys alongside the first previews, so it could be the one that lost.Change:
pickPort(probe, taken)skips any port a live process of this forge already holds.startProcessclaims its port before spawning and releases it when the process exits.scripts/gate.tsmovestest/apps-idle.test.tsout of EXCLUDED and into GATE, and admits the new test too.test/pick-port.test.tschecks that a held port is never re-offered. It is a unit test of the picker, not a reproduction of the race.Left out: I did not change the port handling beyond that. The probe-and-close gap against other programs on the machine remains, since the forge can't see ports it didn't hand out. The test's existing wait for production and its error message stay, so a recurrence will say why it failed.
Sandbox note: the sandbox blocks unix-socket listens, so I ran the tests and pushed with it disabled for those commands. The rest, including the
bun testruns for the gate-list tests, ran inside it.Try it:
bun test test/apps-idle.test.ts test/pick-port.test.ts test/check-list.test.ts🤖 Generated with Claude Code
Closes #583