Skip to content

main-update.test.ts and main-stop.test.ts start standalone workers on the default HTTP port 4701 and fail with EADDRINUSE beside other daemon test files #1417

Closed

Description

@V3RON

Two more daemon tests start a standalone worker with HTTP at the default 127.0.0.1:4701 (ADR 0046), so they fail with EADDRINUSE beside any other file that binds 4701:

  • src/daemon/main-update.test.ts:329: startChecked(off, { configOverrides: { update: { check: false } } }). ...overrides (line 62) replaces configOverrides, so STANDALONE_OFF is dropped.
  • src/daemon/main-stop.test.ts:692: options() (line 668) sets no configOverrides at all.

Holding 4701 with a plain listener and running pnpm exec vitest run --project unit src/daemon src/agent-device src/leasing src/gateway src/cli src/core:

FAIL src/daemon/main-stop.test.ts > startDaemon gateway uplink when the socket claim fails > never dials the gateway when the worker's socket is already claimed
FAIL src/daemon/main-update.test.ts > startDaemon version check > a daemon runs the version check at start without delaying ready, ...
Error: listen EADDRINUSE: address already in use 127.0.0.1:4701

Found while triaging #1414.

Written by an agent.

Activity

  1. added
    bug:new
    on Nov 7, 2026
  2. self-assigned this
    on Nov 7, 2026
  3. V3RON commented on Nov 7, 2026

    @V3RON
    ContributorAuthor

    This was generated by AI during triage.

    Reproduction

    Confirmed both test-fixture defects on origin/main (fc5ac8c3). Extended existing tests; no hardware needed.

    Repro: bug/1417-repro, 57aeead186bf54c7826072fa55eb9905f9617f4c.

    pnpm exec vitest run --project unit src/daemon/main-update.test.ts src/daemon/main-stop.test.ts
    
    main-update.test.ts:
    "the test start helpers start gateways while port 4700 is taken and workers with update overrides while port 4701 is taken"
    Expected ["started", "started"]
    Received ["started", "Error: listen EADDRINUSE: address already in use 127.0.0.1:4701"]
    
    main-stop.test.ts:
    "starts the socket holder while port 4701 is taken and never dials the gateway when the worker's socket is already claimed"
    expect(first).resolves.toBeDefined() rejects with EADDRINUSE at 127.0.0.1:4701
    
    2 failed | 21 passed (23)
    

    Root cause

    Defect in test setup, not daemon behavior. src/daemon/main-update.test.ts:62 spreads overrides after STANDALONE_OFF; the update-only config at line 329 replaces those defaults. src/daemon/main-stop.test.ts:670-673 omits config for the first, standalone worker. Both therefore inherit HTTP enabled on 4701 (src/core/config.ts:876-878). ADR 0046 requires that production default and tells test harnesses to disable unneeded HTTP and agent-device.

    Simplest fix

    Merge overrides.configOverrides onto the role-specific test defaults in startChecked, after spreading other options. In the uplink fixture, always set configOverrides with STANDALONE_OFF, adding gateway config when supplied.

    Temporarily applied both changes, then removed them. The same command passed all 23 tests; after removal, both named failures returned. Only reproduction changes were pushed.

    Alternatives rejected

    • Allocate ephemeral HTTP ports: neither affected worker needs HTTP.
    • Serialize test files: a host daemon can still hold 4701.

    Risk

    • Preserve the gateway helper's allocated port and explicit config overrides.
    • Keep the uplink test's existing no-dial assertion and socket-claim setup.

    Fast track

    • Defect: yes
    • Fix tried: yes
    • Nothing public added or broken: yes
    • No ADR or rule changed: yes
    • One fix: yes

    Written by an agent.

  4. removed their assignment
    on Nov 7, 2026
  5. added
    bug:ready
    and removed
    bug:new
    on Nov 7, 2026
  6. self-assigned this
    on Nov 7, 2026
  7. V3RON commented on Nov 7, 2026

    @V3RON
    ContributorAuthor

    Handoff

    Done

    PR #1444 is ready on 66b0cf6ff21ddb24e54983d9c04e83f85528f575. Preserved triage regressions; 23/23 daemon tests pass. Fresh audit, independent review and hardware applicability completed. No blocking findings; slow lane not applicable. Review ledger, checklist evidence and Status are posted.

    Not done

    Merge through .agents/scripts/merge-pr.sh 1444 after all checks settle green. Final body edits and ready transition triggered pending checks; the gate was not started.

    Findings

    R1 was rejected by an Opus/high occupied-port probe: the gateway-connected worker rejects on the socket claim, not HTTP binding. No public surface or docs change. Review cap used: round 1 only.

    Blocked on

    Nothing requiring maintainer intervention. This is a checks-wait transfer to the parent: watch PR #1444, inspect new failures if any, then run the gate without a waiting loop. Claim released for resumption.

    Written by an agent.

  8. removed their assignment
    on Nov 7, 2026
  9. V3RON commented on Nov 7, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: none.
    Parked: none.
    Waiting: #1417 — PR #1444 final metadata checks; ready, reviewed, no blocking findings. Parent resumes the gate after checks pass.
    Decided: none.

    Written by an agent.

  10. V3RON commented on Nov 7, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: #1444 (#1417).
    Parked: none.
    Waiting: none.
    Decided: none.

    Written by an agent.

  11. added a commit that references this issue on Nov 10, 2026
    1c5d720
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug:ready

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions