test(typed-routes): fix flaky tests by increasing retry timeout#91923
Merged
test(typed-routes): fix flaky tests by increasing retry timeout#91923
Conversation
The dev server emits "Ready in X" before `setupDevBundler` completes, so `routes.d.ts` may not exist yet when tests start polling. The default 3000ms retry window is too short on loaded CI runners. Increase the timeout to 30000ms for the three affected tests, and add a guard in `should have passing tsc after start` to ensure `routes.d.ts` is written before stopping the server and running tsc. Co-Authored-By: Claude <[email protected]>
Collaborator
Stats from current PR✅ No significant changes detected📊 All Metrics📖 Metrics GlossaryDev Server Metrics:
Build Metrics:
Change Thresholds:
⚡ Dev Server
📦 Dev Server (Webpack) (Legacy)📦 Dev Server (Webpack)
⚡ Production Builds
📦 Production Builds (Webpack) (Legacy)📦 Production Builds (Webpack)
📦 Bundle SizesBundle Sizes⚡ TurbopackClient Main Bundles
Server Middleware
Build DetailsBuild Manifests
📦 WebpackClient Main Bundles
Polyfills
Pages
Server Edge SSR
Middleware
Build DetailsBuild Manifests
Build Cache
🔄 Shared (bundler-independent)Runtimes
📎 Tarball URL |
Collaborator
Failing test suitesCommit: 6366b7d | About building and testing Next.js
Expand output● app-dir - server-action-period-hash-custom-key › should have a different manifest if the encryption key from process env is changed ● app-dir - server-action-period-hash-custom-key › should have the same manifest if the encryption key from process env is same
Expand output● segment cache (revalidation) › re-fetch visible links after a navigation, if needed |
eps1lon
approved these changes
Mar 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixing a bug
What?
Three tests in
test/e2e/app-dir/typed-routes/typed-routes.test.tswere intermittently failing withFailed to retry within 3000ms:typed-routes › should generate route types correctlytyped-routes › should have passing tsc after starttyped-routes › should correctly convert custom route patterns from path-to-regexp to bracket syntaxWhy?
The test harness marks the dev server as "ready" when it sees
✓ Ready in Xin stdout. However, the server logs this message before completing the full initialization sequence instart-server.ts— specifically beforegetRequestHandlers()resolves, which chains intosetupDevBundler(). Route type generation (routes.d.ts) only completes insidesetupDevBundler's Watchpackaggregatedevent handler.The gap between the "Ready" log and actual
routes.d.tscompletion can exceed 3000ms on loaded CI runners, causing the tests'retry()calls to time out before the file exists.A secondary issue in
should have passing tsc after start: the test callednext.stop()immediately after the server was considered ready, beforeroutes.d.tswas written. This meanttscran against a project missing the generated types, causing type errors even though the server had been healthy.How?
retry()timeout from the default 3000ms to 30000ms for the three affected tests.retry()guard inshould have passing tsc after startto wait forroutes.d.tsto be present and correct before stopping the server. This ensurestscsees complete generated types.Verified by running the full test file 3 consecutive times locally with
NEXT_SKIP_ISOLATE=1 NEXT_TEST_MODE=dev pnpm testheadless— all passes, all 5 tests green each run.