Skip to content

fix(e2e): harness robustness (watch-ignore, WASM streaming, server cleanup)#84

Open
nothingnesses wants to merge 2 commits into
mainfrom
fix/e2e-trunk-watch-ignore
Open

fix(e2e): harness robustness (watch-ignore, WASM streaming, server cleanup)#84
nothingnesses wants to merge 2 commits into
mainfrom
fix/e2e-trunk-watch-ignore

Conversation

@nothingnesses
Copy link
Copy Markdown
Owner

@nothingnesses nothingnesses commented Jun 5, 2026

Three related e2e-harness robustness fixes. The first resolves the post-merge CI flake in #82; the other two address pre-existing weaknesses found while diagnosing it.

1. Stop Trunk watching Playwright output (the CI flake)

The E2E job serves the frontend with trunk serve, whose watcher covers frontend/. Playwright writes traces/screenshots/videos into frontend/test-results/ throughout a run, so the watcher fired a storm of rebuilds mid-test (533 watcher events / ~537 build starts in the failing run). On a CPU-contended runner those rebuilds starved Chromium's WASM compile, leaving the first authenticated page blank past the 10s assertion timeout (the failure screenshot is a blank page; the heading renders with no backend dependency). Backend-integration, storage-integration, and the other 3 e2e tests passed, it is frontend boot starvation, not the merged backend changes.

Fix: add the Playwright output dirs to Trunk's [watch] ignore, and pre-create them in the e2e recipe (Trunk canonicalizes ignore paths at startup).

2. Stream the WASM bundle (faster, sturdier cold boots)

trunk serve does send application/wasm, but Trunk's default SRI integrity on the wasm makes the browser fall back from WebAssembly.instantiateStreaming to the slower non-streaming instantiate of the ~19 MB debug bundle. Pass trunk serve --no-sri in the e2e recipe so the browser can stream-compile. Scoped to e2e; production builds keep SRI.

3. Do not orphan the app servers on cleanup

The backend was launched via cargo run behind a direnv exec/bash wrapper, so the tracked pid was the wrapper and the real server survived on its port after cleanup, blocking the next local run. The backend now execs the prebuilt binary directly, and cleanup frees the backend/frontend ports via a new memory_map_free_port helper (targeted to those ports; no-op without ss). CI is unaffected (no direnv wrapper, fresh runners per job).

Verification (local)

just e2e passes 4/4; watcher test-results events 533 -> 0; the served build has no wasm SRI; both ports are free after the run.

Generated with Claude Code (https://claude.com/claude-code)

just e2e serves the frontend with trunk serve, whose file watcher covers
frontend/. Playwright writes traces, screenshots, and videos into
frontend/test-results/ throughout a run, so the watcher fired a storm of
rebuilds mid-test (500+ events in one CI run). On a CPU-contended runner this
starved the browser's debug-WASM compile/instantiate, leaving the first
authenticated page blank past the 10s assertion timeout and intermittently
failing the suite.

Add the Playwright output dirs to the Trunk [watch] ignore list, and
pre-create them in the e2e recipe because Trunk canonicalizes ignore paths at
startup and errors on missing ones. Verified locally: the watcher no longer
reacts to test artifacts (0 events, down from 533) and the suite passes 4/4.
Two e2e-harness robustness follow-ups flagged while diagnosing the flake:

- Disable SRI for the dev server (trunk serve --no-sri). Trunk's default
  subresource-integrity attribute on the wasm makes the browser fall back from
  WebAssembly.instantiateStreaming to the slower non-streaming instantiate,
  which on the large debug bundle slows cold boots. Scoped to e2e; production
  builds are unchanged.

- Stop orphaning the app servers. The backend now execs the prebuilt binary
  instead of cargo run (avoiding an extra wrapper process), and cleanup frees
  the backend and frontend ports directly via a new memory_map_free_port
  helper. The servers run behind a direnv exec/bash wrapper whose pid is what
  was tracked, so the real server could survive on its port and block the next
  local run. CI is unaffected (no direnv wrapper, fresh runners).

Verified locally: e2e passes 4/4, the served build has no wasm SRI, and both
ports are free after the run.
@nothingnesses nothingnesses changed the title fix(frontend): stop Trunk watching Playwright output during e2e fix(e2e): harness robustness (watch-ignore, WASM streaming, server cleanup) Jun 5, 2026
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