next.js
7d92ac63 - [test] Fix flaky "delay re-prefetch after revalidation" test (#90503)

Commit
51 days ago
[test] Fix flaky "delay re-prefetch after revalidation" test (#90503) The test verified that revalidation triggers a 300ms cooldown before re-prefetching by using fixed `setTimeout` delays (50ms, 150ms, 350ms) in the Node.js test runner racing against browser-side timers. With only ~50ms of buffer, the test flaked whenever server action processing took longer than expected. The test now uses Playwright's fake clock (`page.clock`) to control the browser's `setTimeout` deterministically. The revalidation click is kept outside `act()` because `act()`'s settling loop calls `waitForIdleCallback` with a timeout that advances the fake clock, which would cause the cooldown to fire prematurely. Instead, `page.waitForResponse` synchronizes with the server action completion, then `page.clock.fastForward` controls exactly when the cooldown expires. `act()` is only used for the final `fastForward` to intercept and deliver the re-prefetch response before navigation. [Flakiness metrics](https://app.datadoghq.com/ci/test/runs?query=test_level%3Atest%20%40git.repository.id%3A%22github.com%2Fvercel%2Fnext.js%22%20%40test.name%3A%22segment%20cache%20%28revalidation%29%20delay%20re-prefetch%20after%20revalidation%20to%20allow%20CDN%20propagation%22%20%40test.status%3A%22fail%22%20%40git.branch%3Acanary&agg_m=count&agg_m_source=base&agg_t=count&fromUser=false&index=citest&start=1770719671431&end=1772015671431&paused=false)
Author
Parents
Loading