Skip to content

Flaky console lane: workers.spec.ts route.fetch gets ECONNREFUSED from the daemon it just answered #642

Closed

Description

@V3RON

What happens

The console lane fails intermittently in route.fetch inside the fake-response
helper: the daemon behind the console's own address stops answering.

Error: route.fetch: connect ECONNREFUSED 127.0.0.1:36487
  -> GET http://127.0.0.1:36487/v1/workers
  at e2e/console/workers.spec.ts:95:36 (answerWithoutLoad)

Reproduces on main, predating any change

  • main at 7533c442, run 38865837069: this exact test, workers.spec.ts:332, same error.
  • main at 9c61e886, run 38875647436: the sibling helper route at workers.spec.ts:441
    (answerMemory), same error.
  • PR fix(contract): retire helper import boundary exemptions #627 head ab30214, run 38895703593: workers.spec.ts:332 again; a rerun of the same
    job at the same commit passed.

What is known

  • Only workers.spec.ts is affected, and only through its two page.route helpers, both of
    which call route.fetch() against the daemon after openConsole has already talked to it.
  • 106 of 107 specs pass each time, so the fleet is up; the refused connect looks like a
    race between the page's route interception and the daemon's listener rather than a
    console regression.
  • The lane runs Chromium only for these PRs, so a rerun is cheap and usually passes.

Expected

The console lane's response-rewriting helpers do not fail with a refused connect on a
fleet every other spec in the same run reaches.

Written by an agent.

Activity

  1. added
    bug:new
    flaky-test
    on Oct 16, 2026
  2. added and removed
    bug:new
    on Oct 17, 2026
  3. self-assigned this
    on Oct 17, 2026
  4. V3RON commented on Oct 17, 2026

    @V3RON
    ContributorAuthor

    Confirmed, reproduced deterministically. Test-side gap: the helper rethrows a connect refused when the test's own finally disposes the gateway between interception and its route.fetch().

    Reproduction

    e2e/console/workers-gateway-stops-mid-fetch.spec.ts on bug/642-repro (f0b7a19e):

    pnpm exec playwright test e2e/console/workers-gateway-stops-mid-fetch.spec.ts --project=chromium
    +   "Error: route.fetch: connect ECONNREFUSED 127.0.0.1:55815"   expect(escaped).toEqual([])
    

    Red 3/3, the lane's signature at workers.spec.ts:95:36. It parks one intercepted re-read before its fetch and releases it only after the listener is confirmed gone. Control: the same handler answers first; releasing before the dispose is green. A handler rejection fails the test at the handler line while the body would wait — why CI shows no assertion.

    Root cause

    Gap, in test code. The console re-reads /v1/workers every second (ui/src/data/live/connection.ts:5). The helpers answer that re-read with route.fetch() from the gateway (e2e/console/workers.spec.ts:95), and fleet tests stop the gateway in finally; HttpGateway.stop closes the listener and destroys open sockets (src/http/server.ts:207-219). A poll intercepted before the close and fetched after it is refused; destroyed mid-request it reads as socket hang up. Census, 198 recent Console job runs: 7 failures, all at 95:36 (:332 ×3, :441 ×3, :831 ×1; 6 chromium, 1 firefox), green on rerun.

    Simplest fix

    Catch the connect-level rejection in answerWithoutLoad and answerMemory and drop that re-read (route.abort()) instead of rethrowing, mirroring e2e/helpers/http-daemon.ts. The test's expectation is a proposal; bug:ready accepts it.

    Alternatives rejected

    • page.close() before each dispose — fixes this case, leaves the helper brittle.
    • Delaying the dispose — polling plus teardown makes the window irreducible.
    • Playwright retries — testing rule 5 forbids engineering green.

    Risk

    • Catch connect errors only: a broad catch hides console regressions.
    • long-lists.spec.ts:123 is the same shape; its daemon outlives its tests, so never flakes.
    • Deliver from bug/642-repro, adapting its test to the real helpers.

    Side findings

    Written by an agent.

  5. removed their assignment
    on Oct 17, 2026
  6. added
    bug:ready
    and removed on Oct 17, 2026
  7. self-assigned this
    on Oct 17, 2026
  8. V3RON commented on Oct 17, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: #667 (#642)

    Written by an agent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug:readyflaky-test

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions