Unverified Commit 0d0057cf authored by vercel-fleet-prod[bot]'s avatar vercel-fleet-prod[bot] Committed by GitHub

test: rename loading.js in-flight prefetch test and document the #99706 fix

Co-authored-by: 's avatarTobias Koppers <1365881+sokra@users.noreply.github.com>
parent 6536743f
import { nextTestSetup } from 'e2e-utils' import { nextTestSetup } from 'e2e-utils'
// Repro for the canary flake in // Regression test for navigating while the target's loading-boundary prefetch
// router-autoscroll.test.ts › "Should apply scroll when loading.js is used". // is still in flight (the cause of intermittent failures in
// router-autoscroll.test.ts › "Should apply scroll when loading.js is used").
// //
// Clicking the off-screen link scrolls it into view, which starts the link's // Clicking the off-screen link scrolls it into view, which starts the link's
// loading-boundary prefetch together with the navigation. That prefetch marks // loading-boundary prefetch together with the navigation, and the navigation
// `__PAGE__` (below `loading-scroll/loading.tsx`) as Pending, and the // reads the prefetch's Pending segment entries. The prefetch used to spawn a
// navigation uses `waitForSegmentCacheEntry(...).then(e => e ? e.rsc : null)` // Pending entry for `__PAGE__` too, even though it's below
// as its prefetch data. The prefetch response fulfills `loading-scroll` and // `loading-scroll/loading.tsx` and the server never renders it in that
// rejects `__PAGE__` in the same pass, so `__PAGE__` resolves to `null` and // response. The response then rejected it, the navigation's prefetch data for
// renders as an empty segment instead of suspending into `loading.js`. The // `__PAGE__` resolved to `null`, and the page rendered as an empty segment
// page stays blank until the dynamic response finishes (~5s). // instead of suspending into `loading.js`. It stayed blank until the dynamic
// response finished (~5s). The scheduler now only spawns entries for segments
// at or above a loading boundary (#99706).
// //
// This test forces the ordering that fails: the navigation request is held // This test forces the ordering that exposed it: the navigation request is
// until the loading-boundary prefetch has been issued (so the entries are // held until the loading-boundary prefetch has been issued (so its entries are
// Pending), then the navigation's own response arrives first and the prefetch // Pending), then the navigation's own response arrives first and the prefetch
// lands later. Even with that ordering the outcome depends on React // lands later. Even with that ordering the outcome depends on React
// scheduling, so it's repeated. // scheduling, so it's repeated.
//
// See https://github.com/vercel/next.js/pull/99829 for the fix.
const ITERATIONS = 10 const ITERATIONS = 10
const PREFETCH_DELAY_MS = 500 const PREFETCH_DELAY_MS = 500
// There's no prefetching in dev, and Cache Components uses per-segment // There's no prefetching in dev, and Cache Components uses per-segment
// prefetches instead of the loading-boundary prefetch, so the race only exists // prefetches instead of the loading-boundary prefetch, so this ordering only
// in production without Cache Components. // exists in production without Cache Components.
// @force-gate !dev // @force-gate !dev
// @force-gate !cacheComponents // @force-gate !cacheComponents
describe('router autoscroll - loading.js during in-flight prefetch', () => { describe('router autoscroll - loading.js during an in-flight prefetch', () => {
const { next } = nextTestSetup({ const { next } = nextTestSetup({
files: __dirname, files: __dirname,
}) })
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment