next.js
70593c52 - test: fix repeated-slashes router push navigation race (#101528)

Commit
24 days ago
test: fix repeated-slashes router push navigation race (#101528) ### What? Fixes the flaky `should handle slashes in router push correctly` test in `test/e2e/repeated-slashes`, which regularly needed in-job retries in `test prod` jobs on canary. ### Why? Several of the `router.push()` cases in this test target a missing page, which causes a hard navigation. The test waited only for `document.readyState` to be `interactive`/`complete` — a condition the *old* page already satisfies — so the wait could finish before the navigation completed. The following one-shot `window.location.pathname` read then raced the document swap; Playwright's "Execution context was destroyed" error is converted to `null` by the browser test harness, surfacing in CI as `Expected: "/google.com", Received: null`. ### How? The test now waits for the navigation's end state instead of a readiness signal: a single `retry()` polls the expected pathname, search, hash and router pathname together. Router access is null-safe so a not-yet-hydrated page simply retries rather than throwing. Expected values are unchanged; no timeouts, sleeps or skips were added. The sibling `should have no error from encoded slashes in router push` test already uses this pattern. ### Verification - With the hard-navigation document response temporarily delayed (local probe only, not in this PR), the old test failed 3/5 targeted runs with the same `Received: null` error; the updated test passed 3/3. - The final change passed 5 consecutive full-suite runs with `--retries 0` in the CI `test prod` environment (webpack, `next start`, strict route types) while all local CPUs were saturated. <!-- NEXT_JS_LLM --> <!-- fleet cb079be8-5b28-4404-abab-229818f4069f --> Co-authored-by: vercel-fleet-prod[bot] <318278635+vercel-fleet-prod[bot]@users.noreply.github.com> Co-authored-by: Tobias Koppers <1365881+sokra@users.noreply.github.com>
Author
Parents
Loading