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
e2e flows start a daemon on a released free port without withHttpDaemon's retry #1397
withHttpDaemon (e2e/helpers/http-daemon.ts:13, #560) retries when the port freeLoopbackPort released is taken before the daemon binds it. Some e2e flows still pass that port straight to a daemon, so the e2e lane (4 workers) can fail them with EADDRINUSE:
Confirmed, and wider: 27 flows in 8 files. Test on bug/1397-repro: e2e/picked-ports.test.ts, "the flows that start a daemon on a port they picked pass when another listener takes the first port each one releases". A child vitest run takes and holds the first port each test releases. The control, a GET /v1/stats flow on withHttpDaemon, passes. Without the taker, all 102 tests of those files pass.
pnpm test:e2e e2e/picked-ports.test.ts
- "cancelled when its requester cancels": "passed",
+ "cancelled when its requester cancels": "failed",
... 27 flows "failed"; the withHttpDaemon control "passed"
❯ e2e/picked-ports.test.ts:147:24
Root cause
Defect. freeLoopbackPort (e2e/helpers/port.ts:21) and three local reservePort copies (http-api.test.ts:15, daemon-log.test.ts:47, device-exec.test.ts:23) release the port before returning it. The flows hand it to a daemon that binds later with no retry, so a port taken in between fails the start with EADDRINUSE. Sites the issue missed: http-api.test.ts (60, 216, 315, 348, 420, 469, 512), daemon-log.test.ts:95, device-exec.test.ts:83. Only withHttpDaemon (e2e/helpers/http-daemon.ts:13) retries.
Simplest fix
Switch to withHttpDaemon at lease-limit-per-requester:91, usage-stats:125, physical-leasing:699, the 7 http-api sites, daemon-log:95 and device-exec:83. Delete the reservePort copies.
daemon-folders and daemon-lifecycle:79 start the gateway inside the test (config set, then a start, status or MCP call, or a spawned main.js): move withHttpDaemon's loop into onFreePort(start: (port) => Promise<"started" | "port-taken">) and wrap that step.
Step 1 tried on 3 files: their 7 flows pass, the files stay green:
pnpm test:e2e e2e/picked-ports.test.ts e2e/device-exec.test.ts e2e/daemon-log.test.ts e2e/lease-limit-per-requester.test.ts
Tests 1 failed | 15 passed (16) # picked-ports: those 7 "passed", the other 20 still "failed"
Alternatives rejected
vitest retry on these files: it retries every failure and hides real flakes (testing rule 5).
Hold the port until the bind: the daemon is another process.
Risk
About 9 files, over the gate's 8: two PRs, step 1 then step 2.
The reproduction reruns 28 flows (about 30 s green, 2.7 min red): keep it or drop it after the fix.
Not checked: the slow lane, e2e/console/fixtures.ts (221, 596, 643), e2e/helpers/env.test.ts:114, the registry port in e2e/update/update.e2e.test.ts:22.
Closing as a duplicate of #1395 at the maintainer's request. Its e2e call sites are now part of #1395's scope (comment "Scope added: the e2e flows (from #1397)"). The repro test stays on bug/1397-repro.
Activity
V3RON commentedon Nov 6, 2026
Reproduction
Confirmed, and wider: 27 flows in 8 files. Test on
bug/1397-repro:e2e/picked-ports.test.ts, "the flows that start a daemon on a port they picked pass when another listener takes the first port each one releases". A child vitest run takes and holds the first port each test releases. The control, aGET /v1/statsflow onwithHttpDaemon, passes. Without the taker, all 102 tests of those files pass.Root cause
Defect.
freeLoopbackPort(e2e/helpers/port.ts:21) and three localreservePortcopies (http-api.test.ts:15,daemon-log.test.ts:47,device-exec.test.ts:23) release the port before returning it. The flows hand it to a daemon that binds later with no retry, so a port taken in between fails the start with EADDRINUSE. Sites the issue missed:http-api.test.ts(60, 216, 315, 348, 420, 469, 512),daemon-log.test.ts:95,device-exec.test.ts:83. OnlywithHttpDaemon(e2e/helpers/http-daemon.ts:13) retries.Simplest fix
withHttpDaemonatlease-limit-per-requester:91,usage-stats:125,physical-leasing:699, the 7http-apisites,daemon-log:95anddevice-exec:83. Delete thereservePortcopies.daemon-foldersanddaemon-lifecycle:79start the gateway inside the test (config set, then a start, status or MCP call, or a spawnedmain.js): movewithHttpDaemon's loop intoonFreePort(start: (port) => Promise<"started" | "port-taken">)and wrap that step.Step 1 tried on 3 files: their 7 flows pass, the files stay green:
Alternatives rejected
retryon these files: it retries every failure and hides real flakes (testing rule 5).http.port: 0(Test helpers pick a loopback port, release it, and bind it later: any process in a parallel lane can take it first #1395).Risk
e2e/console/fixtures.ts(221, 596, 643),e2e/helpers/env.test.ts:114, the registry port ine2e/update/update.e2e.test.ts:22.Fast track
Written by an agent.
V3RON commentedon Nov 6, 2026
Closing as a duplicate of #1395 at the maintainer's request. Its e2e call sites are now part of #1395's scope (comment "Scope added: the e2e flows (from #1397)"). The repro test stays on
bug/1397-repro.Written by an agent.