Skip to content

e2e: the dev server no longer watches Playwright's output; story requests use their own connection - #54

Merged
reoring merged 1 commit into
mainfrom
fix/mock-stories-flake
Dec 4, 2026
Merged

reoring merged 1 commit into
mainfrom
fix/mock-stories-flake

Conversation

@reoring

@reoring reoring commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Problem

console-mock-stories failed in 4 of the last 6 attempts on #52 and main, each time in a different story:

Run / attempt Story Symptom
46818920372 / 1 app-create-destination apiRequestContext.get: read ECONNRESET
46818920372 / 2 discover-navigation 30 s test timeout
47285713094 / 1 app-settings-update 60 s test timeout
47285713094 / 2 discover-navigation 30 s test timeout (page.goto)

Cause 1: the Vite dev server watched Playwright's output (the timeouts)

Evidence from the HTML reports of those attempts: the mockReset fixture (two POSTs through Vite to the mock, the same in every story) takes ~90 ms in a fresh worker and grows with every story the worker has run, up to ~900 ms after 75 stories. It drops back to ~90 ms right after a failure restarts the worker. The same stories take 2-3x longer late in a worker (discover-navigation: 24 s after 59 stories, over its 30 s limit after 81).

outputDir is e2e/results, inside the directory Vite serves. Playwright keeps each story's trace there until the worker ends (.playwright-artifacts-<worker>, ~10,800 files by the end of a run). Vite ignores Playwright's default test-results but not this path, so its watcher follows the growing tree and the server's one thread saturates.

Local measurement, same 35 stories, one worker:

Vite CPU Run time Slowest probe through Vite
before 93.3 s 174 s 55 ms
after 6.6 s 158 s 2 ms

Before the change Vite reached ~93% of one core in the last third of the run. Direct requests to the mock stayed at 0.3 ms throughout, so the mock is not involved.

Fix: server.watch.ignored excludes e2e/results and playwright-report.

Cause 2: page.request reused a closing keep-alive socket (the ECONNRESET)

#17 fixed this race for the mock control requests only. 14 story reads went through page.request, which pools sockets; the failing one was app-create-destination.mock.spec.ts:73.

Fix: the request fixture sends every request with connection: close (checked against a counting server: 5 requests, 5 sockets; the default context used 1). The 14 page.request reads use the fixture, and the per-call header in mockControl is gone.

Verification

  • Full suite locally with both changes: 87 passed in 9.2 min, one worker; Vite used 15.7 CPU-seconds in total and the probe stayed at ~1 ms to the end.
  • bun run typecheck:e2e, bun run typecheck: clean.

Not verified locally: the CI runner itself. This PR's console-mock-stories run is the first measurement there.

…ests use their own connection

console-mock-stories failed about one run in two, each time in a different story.

- Vite watched e2e/results, where Playwright keeps every story's trace for the life of
  the worker. The server's one thread saturated as that tree grew, every request through
  it slowed with each story, and long stories ran past their timeout. vite.config.ts
  now excludes e2e/results and playwright-report from the watcher.
- page.request reused a keep-alive socket the dev server was closing (ECONNRESET). The
  request fixture sends every request on its own connection; stories use it instead of
  page.request.
@reoring

reoring commented Dec 4, 2026

Copy link
Copy Markdown
Contributor Author

CI measurement for this PR (run 47329464538, first attempt, all jobs green), against the two failing attempts that ran longest:

stories job duration mockReset avg, stories 1-10 41-50 71-78 max
46818920372 / 2 (before) 86 passed, 1 failed 19.8 min 129 ms 407 ms 762 ms 912 ms
47285713094 / 2 (before) 86 passed, 1 failed 19.4 min 116 ms 367 ms 693 ms 1030 ms
this PR 87 passed 10.0 min 68 ms 65 ms 63 ms 86 ms

The stories that timed out: discover-navigation 32.2 s → 5.9 s (limit 30 s), app-settings-update 53.6 s → 15.3 s (limit 60 s).

One green run does not prove the ECONNRESET race is gone (it showed once in six attempts); the fixture change removes socket reuse, which is its cause.

@reoring
reoring merged commit 71d4f88 into main Dec 4, 2026
6 checks passed
reoring added a commit that referenced this pull request Dec 4, 2026
The comment said 60 stories in 10 to 15 minutes. After #54 every @mock story runs in about
10 minutes (runs 47329464538 and 47331303988); the story count is no longer repeated here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant