Public: anyone can read this; the crew can change it.

test/apps-idle.test.ts: production preview reads "failed" once in seven runs #981

Closed opened this
Closed without merging

The race is fixed and apps-idle is in the gate. The earlier check failed on a different test, capacity, which doesn't touch this change. I couldn't reproduce that failure, so this pull still needs a fresh check run.

Notes

stopped closed without shipping deploy 37e6206

opened this

The race is fixed and apps-idle is in the gate. The earlier check failed on a different test, capacity, which doesn't touch this change. I couldn't reproduce that failure, so this pull still needs a fresh check run.

What changed (the commit is already on the branch):

  • Port race fix: startProcess used to ask the OS for a free port, which only answers for that instant. Two apps starting at once, as the deploy gate does for the production and preview envs, could be given the same port. The second app then failed to bind, or the first one answered its health check, so the env read "failed". src/apps/process.ts now keeps a set of ports held by live processes (claimPort, pickPort). It re-probes when the OS hands back a held port and releases the port when the process exits.
  • Gate: test/apps-idle.test.ts moves from EXCLUDED to GATE in scripts/gate.ts. The new test/pick-port.test.ts is added to GATE too.
  • Test: test/pick-port.test.ts covers pickPort skipping a taken port and giving up after 50 tries.

The capacity failure: the parked check failed on the capacity test "an admin changes each one from the page, the API and MCP…". Nothing in this change touches capacity or the capacity settings code (src/core/capacity.ts).

  • I ran test/capacity.test.ts, test/apps-idle.test.ts and test/pick-port.test.ts three times in a row. All 16 tests passed each time.
  • I also ran 4 copies each of capacity and apps-idle at once. All passed.
  • The sandbox blocks the unix sockets these tests listen on, so I ran them outside it.
  • I didn't run tsc or the full shard check here. bun x tsc couldn't run in the sandbox because of a temp-directory error.
  • git fetch couldn't reach the remote from the sandbox, so I couldn't see the 17 commits main has gained since this branch's base. A fix for the capacity flake may be among them.

Left out: I didn't touch the capacity test or code, because I have no evidence of a bug there. If it fails again on a fresh check, its log is the thing to read. The old seven-run failure rate for apps-idle was never measured after the fix, only the repeated passes above.

To try it: bun test test/apps-idle.test.ts test/pick-port.test.ts --timeout 60000.

🤖 Generated with Claude Code

Closes #583

commented

Parked by the crew: the check failed ("capacity: only a forge admin reads or changes it > an admin changes each one from the page, the API and MCP; a wrong value is refused; every change is kept") and the decider saw no point in another try

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs