ci flake, recurring: live-control-plane seams RST on EVERY dashboard suite run — #882's ephemeral-range diagnosis is ruled out #888

Closed
opened 2026-08-27 04:35:55 +00:00 by matou-build-agent · 2 comments

Symptom

ci run 12567 (seam stage, sha 590d40d9) reddened on one test out of 1261:

FAIL tests/unit/mailEntry.test.ts > the mail surface boots over a live control plane (MAIL-M1 → M2 → claimed)
  > shows the would-be address, opens the claim, and lands on webmail
AssertionError: expected null not to be null
 ❯ tests/unit/mailEntry.test.ts:116:20
Test Files  1 failed | 109 passed (110)
     Tests  1 failed | 1260 passed (1261)

alongside, in the same worker:

failure: null
  at <SurfaceErrorBoundary>
Error: read ECONNRESET
Error: connect ECONNRESET 127.0.0.1:25945

This is the same failure class as #882 (joinEntry, port 41321), on a
different file, after #882's fix (d8f60e81) shipped.
dashboard/tests/unit/mailEntry.test.ts:116 is the first assertion after mount
— expect(m1).not.toBeNull(). It failed because bootMailSurface's first live
round-trip (GET /api/v1/mail/status) was RST, so the surface fell through to
SurfaceErrorBoundary instead of the M1 screen. A transport reset, not a logic
regression.

#882's diagnosis is ruled out — its fix treated a symptom

#882 concluded the RST was a loopback self-connect: server.listen(0) binds
inside the host ephemeral range (ip_local_port_range = 32768–60999), a client's
own ephemeral source port can land on it, and the kernel answers a
simultaneous-open with RST. d8f60e81 moved every bind into listenLoopback()
(dashboard/tests/support/liveServer.ts), a random port in 20000–32767 —
below the ephemeral floor, where that collision is structurally impossible.

Verified applied: 24 seam files import listenLoopback; zero listen(0)
remain.

But every port in every reset observed since is inside 20000–32767 — the
band listenLoopback binds into, which no client source port can ever equal:

where port inside 20000–32767?
ci run 12567 (this red) 25945 yes
local full-suite run 1 23979 yes
local full-suite run 2 29670 yes
local full-suite run 3 29433 yes
local verbose run 23342 yes
local verbose run 25920 yes

So the band change did not remove the cause. It only re-rolled the dice.

New evidence: this is NOT rare, and NOT a port collision

Healer investigation on matou-workstation, workdir tip 747ab179:

  • mailEntry.test.ts alone × 15 → 15/15 green, zero ECONNRESET. File-local
    logic is fine.
  • Full dashboard suite × 3 → a connect ECONNRESET in 3 of 3 runs
    (23979, 29670, 29433) — yet 110/110 files passed each time. The reset is a
    constant background condition of the suite; whether it reds depends only on
    whether it lands on a request a live assertion is awaiting. #882's "1 in 1258"
    framing understated it badly.
  • vitest run --no-file-parallelism × 2 → the reset still happens (31009,
    29952), 110/110 green. With one worker and one server listening at a time,
    cross-worker port collision cannot be the cause. That family is dead.
  • Under --reporter=verbose the reset is emitted unattributed to any test,
    from happy-dom's Fetch.onError — i.e. a client fetch fired between tests,
    after the owning file's tests finished (see pendingLive → monitoringAlertContact
    boundary in the log). That points at a late/in-flight fetch from a disposed
    surface meeting its control plane's server.close()
    : closing a listening
    socket with a SYN still in its accept queue makes the kernel RST it, which the
    client reports as connect ECONNRESET (a closed port would give ECONNREFUSED).
  • ss -ltn: nothing on the host listens in 20000–32767 except mongod:27017.
  • CI runs pnpm -r run test (scripts/seam-smoke.sh:133) — dashboard, app,
    openapi-spec and ui-kit suites run concurrently, so CI carries more load
    than the dashboard-only reproduction above. host.txt for this incident also
    shows the runner under memory pressure (2080 MB swap in use, 2190 MB free),
    which widens any accept-queue race.

The exact triggering mechanism is not yet identified. What is established is
what it is not: not file-local, not cross-worker port collision, not ephemeral
self-connect, not rare.

What a fix should decide

#882 listed three options and shipped option 1 (bind outside the ephemeral
range). Option 1 is now falsified. The remaining honest choices:

  1. Find the real reset window in the harness — most likely the teardown
    order in each seam's afterEach (dispose() → settle() → server.close()):
    ensure no surface can have a fetch in flight or a keep-alive socket open when
    close() runs, and destroy live sockets deterministically rather than relying
    on settle()'s 30 ms. Covers all 24 seams; product code untouched.
  2. Give the live transports a bounded retry on transport-level faults
    (ECONNRESET/ECONNREFUSED only, never an HTTP status). #882 flagged this as
    a real product decision — a member's phone on a flaky link arguably deserves
    it — but it must not mask a genuinely dead control plane: the honest dead ends
    (S3x / M2x) and SurfaceErrorBoundary have to stay reachable (ADR 0100).
  3. Accept it and record it — no longer defensible: seam gates publish and
    publish-broker, so a random red stops the reseed and broker rails on main,
    and the reset now demonstrably fires on every run.

Per ADR 0174 this is a two-way door (revertible by commit, provable by the
reproduction above), so an agent may rule between 1 and 2 and proceed.

Acceptance

  • The reproduction commands below run clean: 20 consecutive full-suite runs
    with zero ECONNRESET in any log
    , not merely zero failed tests. A green
    suite that still logs the reset has not fixed this.
  • Whatever is chosen, docs/GOTCHAS.md gains an entry — #882 closed without one,
    which is part of why this recurred unrecognised.

Reproduction

cd dashboard
# reds nothing but logs the reset ~every run:
node_modules/.bin/vitest run --reporter=basic 2>&1 | grep -i econnreset
# still resets with a single worker:
node_modules/.bin/vitest run --no-file-parallelism --reporter=basic 2>&1 | grep -i econnreset
# attribute it:
node_modules/.bin/vitest run --reporter=verbose 2>&1 | grep -B25 "connect ECONNRESET"

Evidence

  • ci run: https://git.matou.nz/Matou/idss/actions/runs/12567
  • healer signature: 5863482b87fa (#882's was ba24de31e015)
  • verdict marker stage: TypeScript: build (tsc), test (vitest), lint (eslint), exit 1
  • prior issue: #882 (closed); its fix: d8f60e81
  • harness under suspicion: dashboard/tests/support/liveServer.ts, and the
    afterEach teardown shared by the 24 seams that import it
## Symptom `ci` run 12567 (seam stage, sha `590d40d9`) reddened on **one** test out of 1261: ``` FAIL tests/unit/mailEntry.test.ts > the mail surface boots over a live control plane (MAIL-M1 → M2 → claimed) > shows the would-be address, opens the claim, and lands on webmail AssertionError: expected null not to be null ❯ tests/unit/mailEntry.test.ts:116:20 Test Files 1 failed | 109 passed (110) Tests 1 failed | 1260 passed (1261) ``` alongside, in the same worker: ``` failure: null at <SurfaceErrorBoundary> Error: read ECONNRESET Error: connect ECONNRESET 127.0.0.1:25945 ``` This is the **same failure class as #882** (`joinEntry`, port 41321), on a different file, **after #882's fix (`d8f60e81`) shipped**. `dashboard/tests/unit/mailEntry.test.ts:116` is the first assertion after mount — `expect(m1).not.toBeNull()`. It failed because `bootMailSurface`'s first live round-trip (`GET /api/v1/mail/status`) was RST, so the surface fell through to `SurfaceErrorBoundary` instead of the M1 screen. A transport reset, not a logic regression. ## #882's diagnosis is ruled out — its fix treated a symptom #882 concluded the RST was a **loopback self-connect**: `server.listen(0)` binds inside the host ephemeral range (`ip_local_port_range = 32768–60999`), a client's own ephemeral source port can land on it, and the kernel answers a simultaneous-open with RST. `d8f60e81` moved every bind into `listenLoopback()` (`dashboard/tests/support/liveServer.ts`), a random port in **20000–32767** — below the ephemeral floor, where that collision is structurally impossible. Verified applied: **24 seam files import `listenLoopback`; zero `listen(0)` remain.** But **every port in every reset observed since is inside 20000–32767** — the band `listenLoopback` binds into, which no client source port can ever equal: | where | port | inside 20000–32767? | |---|---|---| | ci run 12567 (this red) | 25945 | yes | | local full-suite run 1 | 23979 | yes | | local full-suite run 2 | 29670 | yes | | local full-suite run 3 | 29433 | yes | | local verbose run | 23342 | yes | | local verbose run | 25920 | yes | So the band change did not remove the cause. It only re-rolled the dice. ## New evidence: this is NOT rare, and NOT a port collision Healer investigation on `matou-workstation`, workdir tip `747ab179`: - **`mailEntry.test.ts` alone × 15 → 15/15 green, zero ECONNRESET.** File-local logic is fine. - **Full dashboard suite × 3 → a `connect ECONNRESET` in 3 of 3 runs** (23979, 29670, 29433) — yet **110/110 files passed each time**. The reset is a *constant background condition* of the suite; whether it reds depends only on whether it lands on a request a live assertion is awaiting. #882's "1 in 1258" framing understated it badly. - **`vitest run --no-file-parallelism` × 2 → the reset still happens** (31009, 29952), 110/110 green. With one worker and one server listening at a time, **cross-worker port collision cannot be the cause.** That family is dead. - Under `--reporter=verbose` the reset is emitted **unattributed to any test**, from happy-dom's `Fetch.onError` — i.e. a client fetch fired *between* tests, after the owning file's tests finished (see `pendingLive` → `monitoringAlertContact` boundary in the log). That points at a **late/in-flight fetch from a disposed surface meeting its control plane's `server.close()`**: closing a listening socket with a SYN still in its accept queue makes the kernel RST it, which the client reports as `connect ECONNRESET` (a *closed* port would give ECONNREFUSED). - `ss -ltn`: nothing on the host listens in 20000–32767 except mongod:27017. - CI runs `pnpm -r run test` (`scripts/seam-smoke.sh:133`) — dashboard, app, openapi-spec and ui-kit suites run **concurrently**, so CI carries more load than the dashboard-only reproduction above. `host.txt` for this incident also shows the runner under memory pressure (2080 MB swap in use, 2190 MB free), which widens any accept-queue race. **The exact triggering mechanism is not yet identified.** What is established is what it is *not*: not file-local, not cross-worker port collision, not ephemeral self-connect, not rare. ## What a fix should decide #882 listed three options and shipped option 1 (bind outside the ephemeral range). Option 1 is now falsified. The remaining honest choices: 1. **Find the real reset window in the harness** — most likely the teardown order in each seam's `afterEach` (`dispose()` → `settle()` → `server.close()`): ensure no surface can have a fetch in flight or a keep-alive socket open when `close()` runs, and destroy live sockets deterministically rather than relying on `settle()`'s 30 ms. Covers all 24 seams; product code untouched. 2. **Give the live transports a bounded retry on transport-level faults** (`ECONNRESET`/`ECONNREFUSED` only, never an HTTP status). #882 flagged this as a real product decision — a member's phone on a flaky link arguably deserves it — but it must not mask a genuinely dead control plane: the honest dead ends (S3x / M2x) and `SurfaceErrorBoundary` have to stay reachable (ADR 0100). 3. **Accept it and record it** — no longer defensible: `seam` gates `publish` and `publish-broker`, so a random red stops the reseed and broker rails on main, and the reset now demonstrably fires on every run. Per ADR 0174 this is a **two-way door** (revertible by commit, provable by the reproduction above), so an agent may rule between 1 and 2 and proceed. ## Acceptance - The reproduction commands below run clean: **20 consecutive full-suite runs with zero `ECONNRESET` in any log**, not merely zero failed tests. A green suite that still logs the reset has not fixed this. - Whatever is chosen, `docs/GOTCHAS.md` gains an entry — #882 closed without one, which is part of why this recurred unrecognised. ## Reproduction ```bash cd dashboard # reds nothing but logs the reset ~every run: node_modules/.bin/vitest run --reporter=basic 2>&1 | grep -i econnreset # still resets with a single worker: node_modules/.bin/vitest run --no-file-parallelism --reporter=basic 2>&1 | grep -i econnreset # attribute it: node_modules/.bin/vitest run --reporter=verbose 2>&1 | grep -B25 "connect ECONNRESET" ``` ## Evidence - ci run: https://git.matou.nz/Matou/idss/actions/runs/12567 - healer signature: `5863482b87fa` (#882's was `ba24de31e015`) - verdict marker stage: `TypeScript: build (tsc), test (vitest), lint (eslint)`, exit 1 - prior issue: #882 (closed); its fix: `d8f60e81` - harness under suspicion: `dashboard/tests/support/liveServer.ts`, and the `afterEach` teardown shared by the 24 seams that import it
Author
Member

swarm-claim host=elitebook-distributed-server-03 run=12576
(automated multi-host claim — lowest live claim id works this ticket)

swarm-claim host=elitebook-distributed-server-03 run=12576 (automated multi-host claim — lowest live claim id works this ticket)
Author
Member

close-report for #888 — status success

✅ close-report gates passed — every claim verified against main; issue closed.

envelope
{
  "issue": 888,
  "status": "success",
  "commits": [
    "da67aaea63f100dd75dd2207c00ab2dffc7a2cac"
  ],
  "changed_files": [
    "STATUS.md",
    "docs/GOTCHAS.md",
    "dashboard/tests/support/liveServer.ts",
    "dashboard/tests/unit/liveServerTeardown.test.ts",
    "dashboard/tests/unit/activityLive.test.ts",
    "dashboard/tests/unit/backupsLive.test.ts",
    "dashboard/tests/unit/chromeIndicatorsLive.test.ts",
    "dashboard/tests/unit/controlPlaneTracer.test.ts",
    "dashboard/tests/unit/deviceTelemetryLive.test.ts",
    "dashboard/tests/unit/enrollLive.test.ts",
    "dashboard/tests/unit/fleetLive.test.ts",
    "dashboard/tests/unit/joinEntry.test.ts",
    "dashboard/tests/unit/mailEntry.test.ts",
    "dashboard/tests/unit/membersDrillInsLive.test.ts",
    "dashboard/tests/unit/membersLive.test.ts",
    "dashboard/tests/unit/mountProvisioningUpdates.test.ts",
    "dashboard/tests/unit/networkLive.test.ts",
    "dashboard/tests/unit/overviewLive.test.ts",
    "dashboard/tests/unit/pendingActsLive.test.ts",
    "dashboard/tests/unit/pendingLive.test.ts",
    "dashboard/tests/unit/provisionLive.test.ts",
    "dashboard/tests/unit/recoveryReadinessLive.test.ts",
    "dashboard/tests/unit/rescueLive.test.ts",
    "dashboard/tests/unit/serveEntry.test.ts",
    "dashboard/tests/unit/settingsLive.test.ts",
    "dashboard/tests/unit/updatesLive.test.ts"
  ],
  "tests": [
    {
      "command": "cd dashboard && vitest run tests/unit/liveServerTeardown.test.ts",
      "exit_code": 0
    },
    {
      "command": "cd dashboard && vitest run (full suite, 111 files / 1263 tests)",
      "exit_code": 0
    },
    {
      "command": "20x: cd dashboard && vitest run --reporter=basic | grep -i econnreset (0 hits)",
      "exit_code": 0
    },
    {
      "command": "45x: cd dashboard && vitest run --reporter=verbose (0 connect/read ECONNRESET)",
      "exit_code": 0
    },
    {
      "command": "eslint dashboard/tests/ && prettier --check (new files)",
      "exit_code": 0
    }
  ],
  "criteria": {
    "20 consecutive full-suite runs with zero ECONNRESET in any log (not merely zero failed tests)": "65 consecutive clean runs recorded (20 basic + 45 verbose), all grepped for connect/read ECONNRESET and code:'ECONNRESET' — zero hits; contrasted against the pre-fix baseline that logged the reset on ~every run. closeLiveServer drains happyDOM in-flight fetches before server.close (dashboard/tests/support/liveServer.ts).",
    "docs/GOTCHAS.md gains an entry (#882 closed without one)": "docs/GOTCHAS.md #102 added in commit da67aae — Symptom/Cause/Rule/Source, records the falsification of #882's ephemeral theory and the teardown-race fix.",
    "Rule between option 1 and option 2 and proceed (two-way door, ADR 0174)": "Chose option 1 (harness teardown fix, no product code): closeLiveServer awaits happyDOM.waitUntilComplete() before server.close(); 22 seam close: factories + serveEntry inline teardown migrated. ADR 0100 honest dead ends untouched. Ruled by agent under ADR 0174."
  },
  "summary": "Killed the recurring live-server seam ECONNRESET at its true cause — a teardown race, not #882's ephemeral bind — by draining happy-dom's in-flight fetches before server.close(); proven by 65 consecutive clean full-suite runs.",
  "reason": "",
  "blockers": []
}
**close-report** for #888 — status `success` :white_check_mark: **close-report gates passed** — every claim verified against main; issue closed. <details><summary>envelope</summary> ```json { "issue": 888, "status": "success", "commits": [ "da67aaea63f100dd75dd2207c00ab2dffc7a2cac" ], "changed_files": [ "STATUS.md", "docs/GOTCHAS.md", "dashboard/tests/support/liveServer.ts", "dashboard/tests/unit/liveServerTeardown.test.ts", "dashboard/tests/unit/activityLive.test.ts", "dashboard/tests/unit/backupsLive.test.ts", "dashboard/tests/unit/chromeIndicatorsLive.test.ts", "dashboard/tests/unit/controlPlaneTracer.test.ts", "dashboard/tests/unit/deviceTelemetryLive.test.ts", "dashboard/tests/unit/enrollLive.test.ts", "dashboard/tests/unit/fleetLive.test.ts", "dashboard/tests/unit/joinEntry.test.ts", "dashboard/tests/unit/mailEntry.test.ts", "dashboard/tests/unit/membersDrillInsLive.test.ts", "dashboard/tests/unit/membersLive.test.ts", "dashboard/tests/unit/mountProvisioningUpdates.test.ts", "dashboard/tests/unit/networkLive.test.ts", "dashboard/tests/unit/overviewLive.test.ts", "dashboard/tests/unit/pendingActsLive.test.ts", "dashboard/tests/unit/pendingLive.test.ts", "dashboard/tests/unit/provisionLive.test.ts", "dashboard/tests/unit/recoveryReadinessLive.test.ts", "dashboard/tests/unit/rescueLive.test.ts", "dashboard/tests/unit/serveEntry.test.ts", "dashboard/tests/unit/settingsLive.test.ts", "dashboard/tests/unit/updatesLive.test.ts" ], "tests": [ { "command": "cd dashboard && vitest run tests/unit/liveServerTeardown.test.ts", "exit_code": 0 }, { "command": "cd dashboard && vitest run (full suite, 111 files / 1263 tests)", "exit_code": 0 }, { "command": "20x: cd dashboard && vitest run --reporter=basic | grep -i econnreset (0 hits)", "exit_code": 0 }, { "command": "45x: cd dashboard && vitest run --reporter=verbose (0 connect/read ECONNRESET)", "exit_code": 0 }, { "command": "eslint dashboard/tests/ && prettier --check (new files)", "exit_code": 0 } ], "criteria": { "20 consecutive full-suite runs with zero ECONNRESET in any log (not merely zero failed tests)": "65 consecutive clean runs recorded (20 basic + 45 verbose), all grepped for connect/read ECONNRESET and code:'ECONNRESET' — zero hits; contrasted against the pre-fix baseline that logged the reset on ~every run. closeLiveServer drains happyDOM in-flight fetches before server.close (dashboard/tests/support/liveServer.ts).", "docs/GOTCHAS.md gains an entry (#882 closed without one)": "docs/GOTCHAS.md #102 added in commit da67aae — Symptom/Cause/Rule/Source, records the falsification of #882's ephemeral theory and the teardown-race fix.", "Rule between option 1 and option 2 and proceed (two-way door, ADR 0174)": "Chose option 1 (harness teardown fix, no product code): closeLiveServer awaits happyDOM.waitUntilComplete() before server.close(); 22 seam close: factories + serveEntry inline teardown migrated. ADR 0100 honest dead ends untouched. Ruled by agent under ADR 0174." }, "summary": "Killed the recurring live-server seam ECONNRESET at its true cause — a teardown race, not #882's ephemeral bind — by draining happy-dom's in-flight fetches before server.close(); proven by 65 consecutive clean full-suite runs.", "reason": "", "blockers": [] } ``` </details>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#888
No description provided.