[PR #6730] [MERGED] test(e2e): wait for the page's own fetches before reloading (WebKit sprite flake) #7301

Closed
opened 2026-10-23 04:18:26 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/6730
Author: @kolacheee
Created: 9/26/2026
Status: ✅ Merged
Merged: 9/26/2026
Merged by: @kolacheee

Base: staging ← Head: fix/expression-sprites-webkit-flake


📝 Commits (1)

  • fc24778 test(e2e): wait for the page's own fetches before reloading

📊 Changes

4 files changed (+77 additions, -3 deletions)

View changed files

📝 CHANGELOG.md (+2 -0)
📝 e2e/expression-active-sprites.e2e.ts (+6 -2)
➕ e2e/page-fetch-fixture.ts (+66 -0)
📝 e2e/roleplay-commands.e2e.ts (+3 -1)

📄 Description

Important

Contributions target staging. Only SpicyMarinara may promote this repository's staging branch or a same-repository hotfix/* branch to main.
Outside and first-time contributors also require an approving review from SpicyMarinara.

Linked issue

Closes #6677

Why this change

  • The expression sprite spec failed on mobile-webkit, in its visual-novel variant, with WebKit page errors such as "Fetch API cannot load … due to access control checks". The URLs were the page's own requests: /api/chats, message-count, messages?limit=20, game-state and generate/status. WebKit reports a fetch that a reload cuts off this way.
  • The spec's reload helper guarded against that with page.waitForLoadState("networkidle"). That wait does nothing after a document's first idle moment: it resolves at once for the rest of that document's life. Measured with a local script on Chromium, the first wait took 500 ms, and a second wait with a 2-second fetch still pending returned in 0 ms.
  • Development PRs no longer run mobile-webkit, but release PRs to main, manual runs and the planned nightly job still do. A red mobile-webkit job there would block a promotion.
  • The Roleplay whisper spec's reload helper relies on the same no-op wait, so it gets the same fix.

What changed

  • e2e/page-fetch-fixture.ts (new):
    • trackPageFetches(page) counts the page's own fetch calls from inside the page, in every document it loads.
    • waitForPageFetchesToSettle(page) waits until no fetch is pending and none has started or ended for half a second.
    • A fetch counts as settled only once its response body has fully arrived, because the page may still be reading the body after the headers come in.
    • It counts inside the page on purpose. A first version tracked Playwright's request, requestfinished and requestfailed events. It got stuck on 1 local run in 4, because a fetch the app cancels itself does not always report a finished or failed request there.
  • e2e/expression-active-sprites.e2e.ts: registers the tracker before the first navigation. Its reload helper waits for generation to finish, then for the page's fetches to settle.
  • e2e/roleplay-commands.e2e.ts: the whisper test registers the tracker and its reload helper uses the same wait instead of networkidle.
  • CHANGELOG.md: one entry under [Unreleased].

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

The boxes are left for a human to tick. What the agent ran:

  • pnpm check and pnpm check:e2e-types: exit 0.
  • Local CodeRabbit (coderabbit review --committed --base-commit <merge-base>): one major finding. fetch resolves when the headers arrive, so a slow response body could still be cut off after the quiet window. Fixed: a fetch now counts as settled only when a clone of its response body has finished arriving. The rerun had no new findings.
  • Local Chromium, desktop project:
    • The expression spec passed 8 of 8 runs, both presentations, 4 repeats each.
    • The whisper test passed in two fresh runs, both presentations.
  • mobile-webkit on GitHub's Ubuntu runners, via a throwaway workflow on a fork branch (not part of this PR):
    • Staging's unchanged expression spec passed 48 of 48 runs in isolation, so the flake did not reproduce outside a full shard.
    • With this fix, the expression spec passed 48 of 48 runs (12 repeats, both presentations, 2 rounds) and the whisper test passed 4 of 4. The new wait never timed out.

Manual verification notes

  • WebKit cannot launch on the Fedora machine used here, because Playwright's WebKit build needs Ubuntu system libraries. All WebKit runs above were therefore on GitHub's Ubuntu runners.
  • The original failure happened inside a full mobile-webkit shard, where earlier tests share the server and load it down. Run alone, the unchanged spec passed every time. So the evidence is the mechanism: the old guard was measured to be a no-op, and the new wait holds on WebKit without timing out. It is not a before-and-after failure count.
  • Manually verify the next full mobile-webkit run, on a release PR to main or a manual run of the Regression Checks workflow, stays green for expression-active-sprites and roleplay-commands.
  • Seen while testing, not changed here: on staging's own version, running the whisper test with --repeat-each=3 locally sometimes fails in its visual-novel variant. "Previous paragraph" does not appear within 10 s, and the remaining repeats then fail during fixture setup. Fresh runs pass.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Translated docs on the docs-i18n branch updated to match, or a [docs-i18n] follow-up issue opened (see CONTRIBUTING.md § Translated documentation)
  • Version/release files updated (only if this PR includes a version bump)

Test-only change with one CHANGELOG.md entry. No user-facing docs change.

UI evidence (if applicable)

Not applicable: no UI change.

Summary by CodeRabbit

  • Tests
    • Improved the reliability of browser release checks by ensuring page requests have completed before affected pages reload. This reduces false WebKit access-control failures during checks and helps distinguish genuine browser issues from reloads that occur while requests are still in progress.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/6730 **Author:** [@kolacheee](https://github.com/kolacheee) **Created:** 9/26/2026 **Status:** ✅ Merged **Merged:** 9/26/2026 **Merged by:** [@kolacheee](https://github.com/kolacheee) **Base:** `staging` ← **Head:** `fix/expression-sprites-webkit-flake` --- ### 📝 Commits (1) - [`fc24778`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fc247780e96a7028a87f65a9c2d9ffdae09ab990) test(e2e): wait for the page's own fetches before reloading ### 📊 Changes **4 files changed** (+77 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `CHANGELOG.md` (+2 -0) 📝 `e2e/expression-active-sprites.e2e.ts` (+6 -2) ➕ `e2e/page-fetch-fixture.ts` (+66 -0) 📝 `e2e/roleplay-commands.e2e.ts` (+3 -1) </details> ### 📄 Description > [!IMPORTANT] > Contributions target `staging`. Only `SpicyMarinara` may promote this repository's `staging` branch or a same-repository `hotfix/*` branch to `main`. > Outside and first-time contributors also require an approving review from `SpicyMarinara`. <!-- See CONTRIBUTING.md § Branches. --> ## Linked issue Closes #6677 ## Why this change - The expression sprite spec failed on mobile-webkit, in its visual-novel variant, with WebKit page errors such as "Fetch API cannot load … due to access control checks". The URLs were the page's own requests: `/api/chats`, `message-count`, `messages?limit=20`, `game-state` and `generate/status`. WebKit reports a fetch that a reload cuts off this way. - The spec's reload helper guarded against that with `page.waitForLoadState("networkidle")`. That wait does nothing after a document's first idle moment: it resolves at once for the rest of that document's life. Measured with a local script on Chromium, the first wait took 500 ms, and a second wait with a 2-second fetch still pending returned in 0 ms. - Development PRs no longer run mobile-webkit, but release PRs to `main`, manual runs and the planned nightly job still do. A red mobile-webkit job there would block a promotion. - The Roleplay whisper spec's reload helper relies on the same no-op wait, so it gets the same fix. ## What changed - `e2e/page-fetch-fixture.ts` (new): - `trackPageFetches(page)` counts the page's own `fetch` calls from inside the page, in every document it loads. - `waitForPageFetchesToSettle(page)` waits until no fetch is pending and none has started or ended for half a second. - A fetch counts as settled only once its response body has fully arrived, because the page may still be reading the body after the headers come in. - It counts inside the page on purpose. A first version tracked Playwright's `request`, `requestfinished` and `requestfailed` events. It got stuck on 1 local run in 4, because a fetch the app cancels itself does not always report a finished or failed request there. - `e2e/expression-active-sprites.e2e.ts`: registers the tracker before the first navigation. Its reload helper waits for generation to finish, then for the page's fetches to settle. - `e2e/roleplay-commands.e2e.ts`: the whisper test registers the tracker and its reload helper uses the same wait instead of `networkidle`. - `CHANGELOG.md`: one entry under `[Unreleased]`. ## Validation - [ ] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [ ] Ran the app, clicked through the changes manually - [ ] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [ ] Above manual verification completed (describe below) - [ ] Read and followed `CONTRIBUTING.md` The boxes are left for a human to tick. What the agent ran: - `pnpm check` and `pnpm check:e2e-types`: exit 0. - Local CodeRabbit (`coderabbit review --committed --base-commit <merge-base>`): one major finding. `fetch` resolves when the headers arrive, so a slow response body could still be cut off after the quiet window. Fixed: a fetch now counts as settled only when a clone of its response body has finished arriving. The rerun had no new findings. - Local Chromium, desktop project: - The expression spec passed 8 of 8 runs, both presentations, 4 repeats each. - The whisper test passed in two fresh runs, both presentations. - mobile-webkit on GitHub's Ubuntu runners, via a throwaway workflow on a fork branch (not part of this PR): - Staging's unchanged expression spec passed 48 of 48 runs in isolation, so the flake did not reproduce outside a full shard. - With this fix, the expression spec passed 48 of 48 runs (12 repeats, both presentations, 2 rounds) and the whisper test passed 4 of 4. The new wait never timed out. ### Manual verification notes - WebKit cannot launch on the Fedora machine used here, because Playwright's WebKit build needs Ubuntu system libraries. All WebKit runs above were therefore on GitHub's Ubuntu runners. - The original failure happened inside a full mobile-webkit shard, where earlier tests share the server and load it down. Run alone, the unchanged spec passed every time. So the evidence is the mechanism: the old guard was measured to be a no-op, and the new wait holds on WebKit without timing out. It is not a before-and-after failure count. - Manually verify the next full mobile-webkit run, on a release PR to `main` or a manual run of the Regression Checks workflow, stays green for `expression-active-sprites` and `roleplay-commands`. - Seen while testing, not changed here: on staging's own version, running the whisper test with `--repeat-each=3` locally sometimes fails in its visual-novel variant. "Previous paragraph" does not appear within 10 s, and the remaining repeats then fail during fixture setup. Fresh runs pass. ## Docs and release impact - [ ] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Translated docs on the `docs-i18n` branch updated to match, or a `[docs-i18n]` follow-up issue opened (see CONTRIBUTING.md § Translated documentation) - [ ] Version/release files updated (only if this PR includes a version bump) Test-only change with one `CHANGELOG.md` entry. No user-facing docs change. ## UI evidence (if applicable) Not applicable: no UI change. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Tests** * Improved the reliability of browser release checks by ensuring page requests have completed before affected pages reload. This reduces false WebKit access-control failures during checks and helps distinguish genuine browser issues from reloads that occur while requests are still in progress. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:18:26 +07:00
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
Pasta-Devs/Marinara-Engine#7301
No description provided.