You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Flaky: relay-promises.timing.test.ts "a 64 MiB download through the gateway arrives byte for byte and finishes within 2.8 s" fails with EADDRINUSE #1394
bug:readyAn agent may fix it.fast-trackBug set ready by the fast-track check, not the maintainer (rule 17).flaky-testNames a test that fails without a code change. Delivery skips its base-commit check.
CI run 42239999547 (PR #1393): the test failed after 29 ms with listen EADDRINUSE: address already in use 127.0.0.1:38067, not on its timing. freeLoopbackPort in src/daemon/test-relay-support.ts picks a port, closes the server and returns the number, so another process can take it before the gateway binds it (pick-then-bind race). The PR does not touch that helper; the same file passed 3 of 3 times locally on the PR head.
Confirmed: the pick-then-bind race is real. In this file the likely thief is the test's own counting proxy, not another process. New test on bug/1394-repro in src/daemon/relay-gateway.e2e.test.ts: "startFleet starts its gateway when the gatewayUrl hook opens a listener on the gateway's port, and the hook's listener does not get that port". The hook listens on the picked port, which forces the case where the proxy's listen(0) draws that port.
pnpm exec vitest run --project unit src/daemon/relay-gateway.e2e.test.ts -t "gatewayUrl hook"
AssertionError: expected 'EADDRINUSE' to be 'started'
❯ src/daemon/relay-gateway.e2e.test.ts:289:21
Root cause
Defect. startFleet (src/daemon/test-relay-support.ts:337-341) picks a port, then calls gatewayUrl(port) at line 338, and only after that starts the gateway on the port (line 341). The timing file's hook starts startCountingProxy, and its listen(0) (line 449) can draw the port that was just freed. The timing lane runs files one at a time, and that CI job ran only that lane. So inside that window the proxy is the only TCP bind in the repo's code.
vitest.config.ts:34 fileParallelism: false (timing project)
CI job log: × a 64 MiB download ... 29ms
Error: listen EADDRINUSE: address already in use 127.0.0.1:38067
Simplest fix
Move line 338 below daemons.push(gateway): the hook runs only after the gateway listens. The gateway does not read workerDials; only the worker does.
Retry the start on EADDRINUSE with a new port: the hook would run again, the proxy from the first try would still be in proxies[0], and the timing file reads proxies[0].
Let http.port take 0: that is a public config change (config.test.ts:1122 refuses it).
Risk
A process outside this process can still take the port in the remaining window. That is the parallel-lane case, filed separately.
bug:readyAn agent may fix it.fast-trackBug set ready by the fast-track check, not the maintainer (rule 17).flaky-testNames a test that fails without a code change. Delivery skips its base-commit check.
Activity
V3RON commentedon Nov 6, 2026
Reproduction
Confirmed: the pick-then-bind race is real. In this file the likely thief is the test's own counting proxy, not another process. New test on
bug/1394-reproinsrc/daemon/relay-gateway.e2e.test.ts: "startFleet starts its gateway when the gatewayUrl hook opens a listener on the gateway's port, and the hook's listener does not get that port". The hook listens on the picked port, which forces the case where the proxy'slisten(0)draws that port.Root cause
Defect.
startFleet(src/daemon/test-relay-support.ts:337-341) picks a port, then callsgatewayUrl(port)at line 338, and only after that starts the gateway on the port (line 341). The timing file's hook startsstartCountingProxy, and itslisten(0)(line 449) can draw the port that was just freed. The timing lane runs files one at a time, and that CI job ran only that lane. So inside that window the proxy is the only TCP bind in the repo's code.Simplest fix
Move line 338 below
daemons.push(gateway): the hook runs only after the gateway listens. The gateway does not readworkerDials; only the worker does.Alternatives rejected
proxies[0], and the timing file readsproxies[0].http.porttake 0: that is a public config change (config.test.ts:1122refuses it).Risk
Fast track
Side findings
Written by an agent.
chore(merge): bring origin/main into the branch (#1394)
V3RON commentedon Nov 6, 2026
Delivery run
Merged: #1396 (#1394)
Parked: none
Waiting: none
Decided: none
Written by an agent.
fix(test): startFleet's gatewayUrl hook runs after the gateway listens (