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
device-rotate.e2e.test.ts starts workers on the default HTTP port 4701 and fails with EADDRINUSE beside other daemon test files #1414
src/daemon/device-rotate.e2e.test.ts:73: startWorker sets http only when a test passes httpPort. The other tests leave HTTP at the worker default (ADR 0046), 127.0.0.1:4701 (src/core/config.ts:1027). When another file in the same run also binds 4701, up to four rotate tests fail:
pnpm exec vitest run --project unit src/core/registry-state-db.test.ts src/daemon src/leasing
FAIL src/daemon/device-rotate.e2e.test.ts > device.rotate > answers a holder's rotate of its iOS-simulator lease ...
Error: listen EADDRINUSE: address already in use 127.0.0.1:4701
This failed in 1 of 8 runs of that set on main (0ebd818), and in every run when two copies of the set ran at once. Nothing on the host was listening on 4701 (lsof). Run alone, the file passes (6/6). src/daemon/test-main.ts:15 warns about this clash.
Confirmed. The test holds 127.0.0.1:4701 itself, so the bug shows on every run, not 1 in 8.
src/daemon/device-rotate.e2e.test.ts › "starts a worker that asks for no HTTP port while another listener holds the standalone worker's default HTTP port 4701" (branch bug/1414-repro):
pnpm exec vitest run --project unit src/daemon/device-rotate.e2e.test.ts
FAIL ... > device.rotate > starts a worker that asks for no HTTP port while another listener holds ...
AssertionError: promise rejected "Error: listen EADDRINUSE: address already…" instead of resolving
❯ src/daemon/device-rotate.e2e.test.ts:116:10
Tests 1 failed | 6 passed (7)
Root cause
Defect in the test helper. src/daemon/device-rotate.e2e.test.ts:73 sets http only when the test passes httpPort. When it does not, the worker keeps the standalone default: HTTP on, at 127.0.0.1:4701 (src/core/config.ts:1025-1027, ADR 0046). So the four tests that call worker() with no port bind 4701, and any other process holding 4701 fails their start. The joined worker in the HTTP test is not hit, because its HTTP is off by default.
Simplest fix
When httpPort is undefined, startWorker sets http: { enabled: false }, as STANDALONE_OFF in test-main.ts:15 does.
Activity
V3RON commentedon Nov 7, 2026
Reproduction
Confirmed. The test holds
127.0.0.1:4701itself, so the bug shows on every run, not 1 in 8.src/daemon/device-rotate.e2e.test.ts› "starts a worker that asks for no HTTP port while another listener holds the standalone worker's default HTTP port 4701" (branchbug/1414-repro):Root cause
Defect in the test helper.
src/daemon/device-rotate.e2e.test.ts:73setshttponly when the test passeshttpPort. When it does not, the worker keeps the standalone default: HTTP on, at127.0.0.1:4701(src/core/config.ts:1025-1027, ADR 0046). So the four tests that callworker()with no port bind 4701, and any other process holding 4701 fails their start. The joined worker in the HTTP test is not hit, because its HTTP is off by default.Simplest fix
When
httpPortis undefined,startWorkersetshttp: { enabled: false }, asSTANDALONE_OFFintest-main.ts:15does.Alternatives rejected
startOnFreePortfor every rotate test: they never call HTTP, so a port they don't need is just more setup.STANDALONE_OFF: it also turns agent-device off, which this bug does not need.Risk
POST /v1/leases/{id}/rotate) still passes its own port, on both the worker and the gateway path.Fast track
Side findings
Written by an agent.
V3RON commentedon Nov 7, 2026
Delivery run
Merged: #1418 (#1414)
Parked: none
Waiting: none
Decided: none
Written by an agent.
fix(test): rotate test workers serve no HTTP unless a test asks for a…