Skip to content

fix(web): navigate once when a cold load redirects off-site - #5121

Closed
tale-code-bot wants to merge 1 commit into
mainfrom
fix/web-ui-alias-single-redirect
Closed

tale-code-bot wants to merge 1 commit into
mainfrom
fix/web-ui-alias-single-redirect

Conversation

@tale-code-bot

Copy link
Copy Markdown
Collaborator

Task: TALE-95 on the Development board ("Web /ui redirect intermittently misses its expected destination in E2E"). Source issue: #4553.

Cause

A cold load of a UI-guide alias (/ui, /en/ui, /de/ui, /fr/ui) that the client answers sends the document off-site twice. In CI that client is vite preview, which falls back to the prerendered home page because there is no dist/ui.html; production's server answers these aliases with a 301 instead.

  1. app/main.tsx awaits router.load() before mounting. The alias's beforeLoad throws redirect({ href: 'https://ui.tale.dev' + search }). Router-core marks it reloadDocument and calls window.location.replace.
  2. main.tsx then mounts <RouterProvider> anyway. Its Transitioner runs router.load() on mount, the redirect fires again, and a second location.replace goes to the same address while the first navigation is committing.

In the failing attempts Chromium committed one navigation and left the other with response headers but no commit and no failure. Playwright 1.58's toHaveURL first waits for the frame's pending navigation to finish, so it never compared the URL. Hence Received: "" and the call log waiting for " https://ui.tale.dev/" navigation to finish....

Evidence

  • Job 113308797831 (run 37776436833, head 4d60debc9263784f98bd74b36d3a4e8576125126):

  • Six later runs, same pattern (first attempt and retry 1 fail, retry 2 passes), all with retained playwright-report-web-attempt-1 artifacts: 39308831526, 39534833719, 40604417755, 40609657664, 40612052605, 40622034139. That is 6 of the 69 web E2E jobs since 2026-10-19. Every retry-1 trace shows the same sequence:

    • /ui is served the prerendered home page.
    • Two document requests to https://ui.tale.dev/ go out 14–21 ms apart, and both are fulfilled by the test's route.
    • The first commits: the screencast ends on "Introduction".
    • The second never finishes (receive: -1), and toHaveURL waits on it for 20 s.
  • Local reproduction. Setup:

    • Chromium headless shell 145.0.7632.6, i.e. Playwright 1.58.2's revision 1208 (CI's).
    • CI's full build (client, SSR, prerender, SEO), but with the networked release fetch skipped, so the tracked snapshot was used.
    • vite preview, --workers=2 --retries=0.

    Results:

    • The existing test failed 7 of 20 attempts on main 0da082051 with the CI signature.
    • With the guide's response held, the page logs router.load → router.navigate({ href: 'https://ui.tale.dev', replace: true }) twice: the first time with React not mounted, the second after the Transitioner mounted. The first request is aborted (net::ERR_ABORTED).
    • The static /ui/ stub (trailing slash) went through the same path three times. Every one of those navigations kept the query.

Fix

app/main.tsx: once the initial load has thrown a redirect marked reloadDocument, loadInitialRoute resolves false. It skips the hash replay, which would also call router.load() again, and the mount. The document is already leaving, so the prerendered page stays until the browser goes.

What still mounts as before:

  • Internal redirects, e.g. /de/hardware-pricing → /de/pricing.
  • Normal loads.
  • Failed loads.

Client navigation to an alias still goes through the routes unchanged; the Transitioner is already mounted there, so it redirects once.

Tests

  • app/main.test.tsx gains three cases:

    • An off-site initial redirect, for /ui?source=cold and for /de/ui?source=cold#intro with the page scrolled, loads once, does not replay the hash and does not mount.
    • An internal redirect still mounts.
    • Old source: the two off-site cases fail (createRoot called; load called twice). Fix: 7/7 pass.
  • tests/e2e/specs/smoke.spec.ts:

    • The single /ui check becomes a cold-load check of /ui, /en/ui, /de/ui and /fr/ui with ?source=cold.
    • It keeps real navigation and the https://ui.tale.dev/?source=cold assertion, and adds a requirement of exactly one document request to the guide per alias.
    • No catch, sleep, longer timeout or retry.
  • E2E results (first attempts only, --retries=0):

    Source Test Passed Failed
    Old main.tsx new cold-load check 7 13 (/ui 7, /fr/ui 3, /en/ui 2, /de/ui 1)
    Fix cold-load check 50 0
    Fix client-navigation check 50 0

    All 13 old-source failures were the pending-navigation timeout.

  • With the guide held, after the fix: each alias and the static /ui/ stub show one load, one navigate and one request, none aborted, and the query is kept.

  • tests/manual/reference/automation.md (the /ui row) and the web README name the cold-load behaviour.

Gates run locally, on this head

  • bun run --filter @tale/web typecheck: exit 0.
  • bun run --filter @tale/web lint: exit 0.
  • bun run --filter @tale/web test: 47 files, 1916 tests passed.
  • bun run --filter @tale/web test:prerender: 821 passed.
  • bun run lint:manual, bun run lint:conflicts and oxfmt --check on the changed files: pass.
  • Commit hooks: pass.
  • The full web E2E suite with --retries=0 is still running locally; its result goes on the task.

Not run

  • bun run check as a whole (other workspaces, lint:links, test:ui): left to this PR's CI.
  • Browsers other than Chromium: the web suite runs only Chromium.
  • docs and ui-docs use the same pre-mount load. They have no off-site redirect today, so they are not changed here.

Closes #4553

A cold load of /ui, /en/ui, /de/ui or /fr/ui that reaches the client (vite
preview, a static host) ran the alias's off-site redirect twice: main.tsx's
initial router.load() called location.replace, then mounting RouterProvider
let its Transitioner load the route again and call it a second time while the
first navigation was committing. Chromium committed one and left the other
unsettled, so Playwright's toHaveURL waited on it until its timeout
(Received "", "waiting for navigation to finish"): the flaky smoke check of
#4553.

main.tsx now skips the hash replay and the mount once the initial redirect is
marked reloadDocument, keeping the prerendered page until the browser leaves.
The smoke check covers every alias on a cold load with its query and requires
exactly one document request to the guide; main.test.tsx pins the mount gate.

Closes #4553
@yannickmonney

Copy link
Copy Markdown
Contributor

The autonomous cycle now lands each task through the merge train instead of its own pull request (.agents/repo.md on train), so this pull request closes. The branch fix/web-ui-alias-single-redirect stays and the task goes on with it: the Reviewer reviews the branch's head on the task and squashes accepted work onto train.

tale-review-bot pushed a commit that referenced this pull request Oct 30, 2026
Reviewed in pull request #5121 and on the task at 643654a.

Closes #4553
Task: TALE-95
tale-code-bot added a commit that referenced this pull request Oct 30, 2026
Reviewed in pull request #5121 and on the task at 643654a.

Closes #4553
Task: TALE-95
tale-code-bot added a commit that referenced this pull request Oct 30, 2026
Reviewed in pull request #5121 and on the task at 643654a.

Closes #4553
Task: TALE-95
@yannickmonney
yannickmonney deleted the fix/web-ui-alias-single-redirect 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.

Web /ui redirect intermittently misses its expected destination in E2E

2 participants