Skip to content

test(web): keep request interception on while hero clips load - #5085

Closed
tale-code-bot wants to merge 1 commit into
mainfrom
fix/web-hero-playback-flake
Closed

tale-code-bot wants to merge 1 commit into
mainfrom
fix/web-hero-playback-flake

Conversation

@tale-code-bot

Copy link
Copy Markdown
Collaborator

Summary

This fixes the flaky E2E test real product hero playback › <locale> uses only its responsive product clips at <width>px (services/web/tests/e2e/specs/product-motion.spec.ts), which failed two release-candidate validations.

  • Cause. Playwright lost the clip's request while it switched request interception off.
  • Fix. Request interception now stays on for the whole describe.
  • Wait. expectPlaying waits on a media event with a 30 s deadline, and its failure message carries the media state.

Closes #4996. Board task: TALE-206 (Development).

Diagnosis

CI traces had expired. Runs 38585257407 and 38700307158 keep only their receipt artifacts; the playwright-report-web-attempt-N reports are past their 14-day retention. I read the job logs instead (jobs 115925522218 and 116308271941). Line numbers are those of 9be5cadac:

  • Every 20 s failure is the playback poll in expectPlaying (:71 via :336), after toHaveCount(1) had passed.
  • Retry update dashboard ui (#508) #2 of de … at 1440px in 38700307158 failed after 2.7 s at :346, with 0 requests.

Local reproduction. On unmodified main 9be5cadac, with --repeat-each=5 and 2 workers, 3 of 30 runs failed, all at the :71 poll.

Instrumented run. It logged CDP Network.* events, page request events and the media element's state on failure. In both stalls:

  • the clip request started in the same millisecond that gotoClientPage returned;
  • it got no response within 20 s;
  • the element stayed at paused:false, readyState:0, networkState:2, error:null.

Cause

gotoClientPage (tests/e2e/helpers/client-page.ts) routes **/* for the document. It removes that route after the client commit, just as hydration requests the in-view clip. Removing a page's last route switches request interception off.

In playwright-core 1.58.2 (server/chromium/crNetworkManager.ts, _updateProtocolRequestInterception), the flag goes false (:151) before Chromium receives Fetch.disable (:165). A request that starts in between is lost in one of two ways:

  • Stall. Chromium pauses the request, and Playwright parks the pause to wait for requestWillBeSent (:274). That event arrives after the flag has flipped, so it is handled as not intercepted (:205-206). Nothing ever continues the paused request, and the video stays at readyState 0 until the poll times out.
  • Lost event. requestWillBeSent arrives first and is parked to wait for a pause (:203) that never comes. No request event fires even though the clip plays, so requests.length is 0.

Change (one file: product-motion.spec.ts)

A route for the whole describe. test.describe('real product hero playback') gets a beforeEach that routes clip requests (mediaRequest) to route.fallback():

  • The helper's unroute then never removes the page's last route, so interception stays on while clips load (:149-150 return early).
  • With interception on, Playwright keeps the HTTP cache off (:159), so no clip can come from cache.
  • A route a test adds later (abort, hold) still runs first, so those tests behave as before.

expectPlaying waits on events. After toHaveCount(1), it listens on the figure for playing and timeupdate in the capture phase. It resolves once the same condition as before holds: !paused, readyState >= 2 and videoWidth > 0.

  • An in-page 30 s deadline bounds the wait. If it passes, the error reports the figure state, the number of videos, currentSrc, paused, readyState, networkState and the media error code.
  • The media-clock progress poll and the data-product-motion-state="playing" check after it are unchanged.

Every assertion stays. Each locale's hero plays only its own responsive WebM, without controls, inside its figure, at 320 and 1440 px. Nothing is skipped, quarantined or loosened.

Open for the reviewer

  • The helper. gotoClientPage has the same window for any request that starts at client commit, and 12 specs use it. Only this describe loads an in-view clip with motion on through it. A fix in the helper would change interception and caching for all 12 specs, so it is left out of this PR. It could be a follow-up issue.
  • The other tests in the describe. The route also covers the tests that load an in-view clip right after gotoClientPage: motion preference, visibility and viewport. It keeps the HTTP cache off for every test in the describe.

Checklist

Tick each box or mark N/A with a short reason. Empty boxes block review.

  • bun run check passes (format, lint, typecheck, all tests). Not run in full.
    • Ran on 89d571cc2, all with exit 0:
      • bunx oxfmt --check;
      • bun run lint:conflicts;
      • bun run --filter @tale/web lint;
      • bun run --filter @tale/web typecheck;
      • bun run --filter @tale/web test (47 files, 1913 tests).
    • bun run lint:links passed (exit 0) on the content before the video → clip rename described under Test plan.
    • Not run:
      • uvx ruff format --check: it would install a tool from outside the lock files;
      • the other workspaces' turbo tasks: this change touches one web E2E spec.
    • This PR's own CI runs the format, lint, types, knip and unit checks.
  • bun run lint:sast passes (Opengrep). Not run: this worker has no Opengrep. The SAST check in this PR's CI runs it.
  • Translations: N/A. Test-only change with no strings.
  • Docs: N/A. Test-only change; nothing is user-visible.
  • README.md / README.de.md / README.fr.md: N/A. Test-only change.

Test plan

Setup.

  • Local Playwright 1.58.2 in services/web, against the prebuilt client: E2E_USE_BUILD=1, vite preview on :3001.
  • This worker has no Chromium 145 (rev 1208), so its Chromium 141 headless shell stood in through PLAYWRIGHT_BROWSERS_PATH.

Command A, run before and after the change:

bunx playwright test tests/e2e/specs/product-motion.spec.ts \
  -g "(de|fr) uses only its responsive product clips" --repeat-each=20 --workers=2

Results.

Run Source Result
Command A (contrast) unmodified main 9be5cadac 13 failed, 67 passed (10.8 min). All 13 failed at the playback poll (:71 via :336): de 1440 ×4, de 320 ×2, fr 1440 ×4, fr 320 ×3.
Command A this change 80 passed (8.9 min)
The whole spec, --workers=2 (29 tests) this change 16 passed, 13 failed. The same 13, run from main's copy of the spec, fail with the same errors.
-g "real product hero playback" PR head 89d571cc2 12 passed, 1 failed (the MP4 fallback)

Why the 13 tests fail here. They need what this worker lacks:

  • H.264. The Chromium 141 headless shell has no H.264, which these tests need:
    • the six "actual encoded product actions … decode in both shipped codecs" tests fail with DEMUXER_ERROR_NO_SUPPORTED_STREAMS;
    • "a failed WebM source still decodes and plays the real MP4 fallback" ends with no <video>.
  • Prerendered pages. The six "prerendered motion fallback … without JavaScript" tests need them, and the local client build has none.

What ran on what. The two Command A runs and the whole-spec run used the change before two later edits:

  • lint's no-shadow rule asked to rename the in-page video to clip;
  • the pre-commit hook formatted the file.

The PR head differs from the tested content only by those two edits. The describe run and the gates ran on the head.

Not run:

  • Chromium 145;
  • the full Playwright (web) job;
  • the queue-only jobs (E2E, Build, UI and the rest).

The merge queue's E2E runs this spec on Chromium 145. Note that a green Playwright (web) job can still hold a failure that passed on retry: look for a Playwright diagnostics notice that names this test.

The real product hero playback test failed two release-candidate
validations (#4996). gotoClientPage removes its catch-all route just as
hydration requests the in-view clip, and removing a page's last route
switches Playwright's request interception off. playwright-core 1.58.2
marks interception off (crNetworkManager.ts:151) before Chromium
receives Fetch.disable (:165). A clip request that starts in between
either stays paused with nothing to continue it, so the video stays at
readyState 0 until the 20 s playback poll times out, or loses its
request event, so the test sees no clip request.

A route on clip requests for the whole real-playback describe keeps
interception on, so gotoClientPage never removes the page's last route
while a clip loads. Routes a test adds later still run first.
expectPlaying now waits in the page for the playing or timeupdate event
with a 30 s deadline, and a clip that never starts fails with its media
state instead of a bare poll timeout.

Test-only change: nothing user-visible, so no docs or translations.

@tale-review-bot tale-review-bot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved at 89d571cc281f4c6449f11ae6de934f6423c1e5f7.

What I checked

  • Diff, read in full (services/web/tests/e2e/specs/product-motion.spec.ts, test-only):
    • Fallback route. A beforeEach registers page.route(mediaRequest, route => route.fallback()) for the real-playback describe. Request interception stays on, so gotoClientPage never removes the page's last route while a clip loads.
    • Safe for other routes. Routes a test adds later still run first. The clip requests the test asserts on come from page.on('request'), so the route hides none of them.
    • Playback wait. expectPlaying now waits in the page for playing/timeupdate, captured on the figure because media events don't bubble. It checks once immediately and has a 30 s deadline that rejects with the media state. The @tale/e2e test timeout is 180 s, so that deadline can fire and report.
    • Test strength. It keeps all its assertions: a single <video>, actual playback, currentTime advancing, and the asserted requests.
  • Repeat runs: I staged and read the Coder's logs.
    • contrast-main-r20-w2.clean.log (spec as on main, 20 repeats × 4 cases): 67 passed, 13 failed, exit 1.
    • fix-r20-w2.clean.log (this head): 80 passed, exit 0.
  • Contract: test(web) commit, commitlint-shaped title, Closes #4996, no user-visible change.
  • CI on this head: all seven CI ready checks pass. Runs: Checks 40919302213, SAST 40919302364, Commitlint 40919302211, Security 40919302311, E2E 40919302844, Build 40919302589, CLI 40919302624.

Not run by me: the spec itself. This sandbox has no Chromium, and on PRs Playwright (web) is skipped; it runs only in the merge queue, which gates this merge.

Note: the root-cause trace is for playwright-core 1.58.2. #5076, the 1.62.1 bump, is queued too. The fallback route is harmless under either version.

@tale-review-bot
tale-review-bot added this pull request to the merge queue Oct 29, 2026
@yannickmonney
yannickmonney removed this pull request from the merge queue due to a manual request Oct 29, 2026
@yannickmonney yannickmonney reopened this Oct 29, 2026
@tale-review-bot

Copy link
Copy Markdown
Collaborator

Not landing yet. The green CI ready checks on the approved head 89d571cc281f4c6449f11ae6de934f6423c1e5f7 came from the pre-0da08205 workflows. (tale-review-bot, Reviewer run b123c4de, read at 22:32 UTC)

  • The newest runs: they were created by the 20:13–20:15 UTC close/reopen. They checked out the merge into the old base: Checks run 40947260765, job 123705783290, logged HEAD is now at 0484096 Merge 89d571cc281f4c6449f11ae6de934f6423c1e5f7 into 9be5cadac.
  • What they skipped: in that run, UI (platform n/4) and UI read skipped. So the heavy suites that .github/CI.md ("Landing on main") now requires on the pull request never ran on this head. My rerun of SAST 40947260885 replays the same old merge commit too.
  • My approval of 89d571cc281f4c6449f11ae6de934f6423c1e5f7 stands. The head needs a fresh pull_request run first, from a close/reopen or a draft→ready, which now merges into 0da08205. Once every required check finishes green on that run, the Reviewer lands it with --match-head-commit 89d571cc281f4c6449f11ae6de934f6423c1e5f7.

@yannickmonney

yannickmonney commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Reopened so the checks run again. The 20:13–20:15 UTC reopen started its runs from a test merge into 9be5cada (before 0da08205), because GitHub had not refreshed it yet. This reopen's runs start from the test merge 9040f41c3d, into 0da08205. The head is unchanged (no new commit).

@yannickmonney

Copy link
Copy Markdown
Contributor

Landed on train as 2ec2a19: squashed at the approved head after the fast gate (formatting, typecheck, build). It reaches main with the merge train's pull request, so this pull request closes without merging.

yannickmonney pushed a commit that referenced this pull request Oct 30, 2026
Reviewed and approved in pull request #5085 at 89d571c.

Closes #4996
Task: TALE-206
@yannickmonney
yannickmonney deleted the fix/web-hero-playback-flake branch October 30, 2026 10:32
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.

ci: the web hero playback test fails now and then in release candidates

3 participants