-
Notifications
You must be signed in to change notification settings - Fork 31.2k
instant: enable navigation validation by default #94312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
aurorascharff
merged 4 commits into
canary
from
aurorascharff/instant-validation-warning-by-default
Jun 2, 2026
+253
−14
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6b359e8
instant: enable navigation validation by default
aurorascharff 5e0e4af
test: update unit-test default to 'warning'
aurorascharff 8ae3383
test: opt collateral fixtures out of 'warning' validation default
aurorascharff 2c5387c
test: add integration test for default validationLevel ('warning')
aurorascharff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
8 changes: 7 additions & 1 deletion
8
test/development/app-dir/error-overlay/error-ignored-frames/next.config.js
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,12 @@ | ||
| /** | ||
| * @type {import('next').NextConfig} | ||
| */ | ||
| const nextConfig = {} | ||
| const nextConfig = { | ||
| experimental: { | ||
| instantInsights: { | ||
| validationLevel: 'manual-warning', | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| module.exports = nextConfig |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| /** | ||
| * @type {import('next').NextConfig} | ||
| */ | ||
| const nextConfig = { | ||
| experimental: { | ||
| instantInsights: { | ||
| validationLevel: 'manual-warning', | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| module.exports = nextConfig |
8 changes: 7 additions & 1 deletion
8
test/development/app-dir/owner-stack-invalid-element-type/next.config.js
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,12 @@ | ||
| /** | ||
| * @type {import('next').NextConfig} | ||
| */ | ||
| const nextConfig = {} | ||
| const nextConfig = { | ||
| experimental: { | ||
| instantInsights: { | ||
| validationLevel: 'manual-warning', | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| module.exports = nextConfig |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,12 @@ | ||
| /** | ||
| * @type {import('next').NextConfig} | ||
| */ | ||
| const nextConfig = {} | ||
| const nextConfig = { | ||
| experimental: { | ||
| instantInsights: { | ||
| validationLevel: 'manual-warning', | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| module.exports = nextConfig |
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
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
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
16 changes: 16 additions & 0 deletions
16
test/e2e/app-dir/instant-validation-level-default/app/bare/page.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // Bare page (no `unstable_instant` config). Under the framework default | ||
| // (`'warning'`), implicit validation fires on this page in dev. The runtime | ||
| // data accessed at the top of the page is the "Suspense too high for instant | ||
| // navigation" violation that instant validation specifically flags. The root | ||
| // layout's Suspense satisfies static-shell validation, so the only error in | ||
| // dev is the instant one. | ||
| import { connection } from 'next/server' | ||
|
|
||
| export default async function Page() { | ||
| await connection() | ||
| return ( | ||
| <main> | ||
| <p>bare page (no unstable_instant), runtime data at the top.</p> | ||
| </main> | ||
| ) | ||
| } |
16 changes: 16 additions & 0 deletions
16
test/e2e/app-dir/instant-validation-level-default/app/explicit-false/page.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // Page explicitly opts out of instant validation. Under the framework | ||
| // default (`'warning'`), this segment-level override suppresses the | ||
| // implicit validation that would otherwise fire on a bare page, so no | ||
| // redbox appears. | ||
| import { connection } from 'next/server' | ||
|
|
||
| export const unstable_instant = false | ||
|
|
||
| export default async function Page() { | ||
| await connection() | ||
| return ( | ||
| <main> | ||
| <p>explicit-false page (segment opts out of validation).</p> | ||
| </main> | ||
| ) | ||
| } |
23 changes: 23 additions & 0 deletions
23
test/e2e/app-dir/instant-validation-level-default/app/layout.tsx
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { Suspense, type ReactNode } from 'react' | ||
|
|
||
| // Validation level is not set in next.config.ts, so the framework default | ||
| // applies. The default is 'warning' — implicit validation fires on bare | ||
| // page/default segments in dev only (build is unaffected unless a segment | ||
| // explicitly escalates with `level: 'experimental-error'`). | ||
| // | ||
| // Children are wrapped in Suspense so that pages with runtime data | ||
| // accessed at the top of the page don't fail static-shell validation | ||
| // (the Suspense fallback renders into the static shell). Instant | ||
| // validation flags "Suspense too high for instant navigation" as an | ||
| // instant-specific violation when it runs. | ||
| export const unstable_instant = false | ||
|
|
||
| export default function RootLayout({ children }: { children: ReactNode }) { | ||
| return ( | ||
| <html> | ||
| <body> | ||
| <Suspense fallback={<p>loading…</p>}>{children}</Suspense> | ||
| </body> | ||
| </html> | ||
| ) | ||
| } |
93 changes: 93 additions & 0 deletions
93
test/e2e/app-dir/instant-validation-level-default/instant-validation-level-default.test.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| import { nextTestSetup } from 'e2e-utils' | ||
| import { expectBuildValidationSkipped } from 'e2e-utils/instant-validation' | ||
| import { waitForNoErrorToast } from '../../../lib/next-test-utils' | ||
|
|
||
| // This fixture intentionally omits `experimental.instantInsights` from | ||
| // next.config.ts. It pins the framework default for `validationLevel` — | ||
| // the framework should resolve the default to `'warning'`, which means | ||
| // implicit validation fires on bare pages in dev. If the framework default | ||
| // ever changes, this test should fail, alerting whoever changes it. | ||
| // | ||
| // For exhaustive coverage of explicit levels and per-segment overrides, | ||
| // see the sibling `instant-validation-level-{warning,manual-warning,error, | ||
| // manual-error}` fixtures. | ||
| describe('instant validation - default level', () => { | ||
| const { next, skipped, isNextDev, isNextStart, isTurbopack } = nextTestSetup({ | ||
| files: __dirname, | ||
| skipStart: true, | ||
| skipDeployment: true, | ||
| env: { | ||
| NEXT_TEST_LOG_VALIDATION: '1', | ||
| }, | ||
| }) | ||
| if (skipped) return | ||
|
|
||
| if (isNextStart && !isTurbopack) { | ||
| it.skip('TODO: snapshot tests for webpack', () => {}) | ||
| return | ||
| } | ||
|
|
||
| if (isNextStart) { | ||
| beforeAll(async () => { | ||
| await next.build({ args: ['--experimental-build-mode', 'compile'] }) | ||
| }) | ||
| afterEach(async () => { | ||
| await next.stop() | ||
| }) | ||
| } else { | ||
| beforeAll(async () => { | ||
| await next.start() | ||
| }) | ||
| } | ||
|
|
||
| const prerender = async (pathname: string) => { | ||
| return await next.build({ | ||
| args: [ | ||
| '--experimental-build-mode', | ||
| 'generate', | ||
| '--debug-build-paths', | ||
| `app${pathname}/page.tsx`, | ||
| ], | ||
| }) | ||
| } | ||
|
|
||
| if (isNextDev) { | ||
| describe('dev', () => { | ||
| it('bare page: framework default matches `warning`, implicit validation fires', async () => { | ||
| const browser = await next.browser('/bare') | ||
| await expect(browser).toDisplayCollapsedRedbox(` | ||
| { | ||
| "code": "E1264", | ||
| "description": "Next.js encountered uncached data during a navigation.", | ||
| "environmentLabel": "Server", | ||
| "label": "Instant", | ||
| "source": "app/bare/page.tsx (10:19) @ Page | ||
| > 10 | await connection() | ||
| | ^", | ||
| "stack": [ | ||
| "Page app/bare/page.tsx (10:19)", | ||
| ], | ||
| } | ||
| `) | ||
| }) | ||
|
|
||
| it('explicit-false page: per-segment opt-out still works under default', async () => { | ||
| const browser = await next.browser('/explicit-false') | ||
| await browser.elementByCss('main') | ||
| await waitForNoErrorToast(browser, { waitInMs: 500 }) | ||
| }) | ||
| }) | ||
| } else { | ||
| describe('build', () => { | ||
| it('bare page: framework default is dev-only, build skips validation', async () => { | ||
| const result = await prerender('/bare') | ||
| expectBuildValidationSkipped(result) | ||
| }) | ||
|
|
||
| it('explicit-false page: per-segment opt-out keeps build clean', async () => { | ||
| const result = await prerender('/explicit-false') | ||
| expectBuildValidationSkipped(result) | ||
| }) | ||
| }) | ||
| } | ||
| }) |
10 changes: 10 additions & 0 deletions
10
test/e2e/app-dir/instant-validation-level-default/next.config.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| import type { NextConfig } from 'next' | ||
|
|
||
| const nextConfig: NextConfig = { | ||
| cacheComponents: true, | ||
| typescript: { | ||
| ignoreBuildErrors: true, | ||
| }, | ||
| } | ||
|
|
||
| export default nextConfig |
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
8 changes: 7 additions & 1 deletion
8
test/e2e/app-dir/non-root-project-monorepo/apps/web/next.config.js
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,12 @@ | ||
| /** | ||
| * @type {import('next').NextConfig} | ||
| */ | ||
| const nextConfig = {} | ||
| const nextConfig = { | ||
| experimental: { | ||
| instantInsights: { | ||
| validationLevel: 'manual-warning', | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| module.exports = nextConfig |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,12 @@ | ||
| /** | ||
| * @type {import('next').NextConfig} | ||
| */ | ||
| const config = {} | ||
| const config = { | ||
| experimental: { | ||
| instantInsights: { | ||
| validationLevel: 'manual-warning', | ||
| }, | ||
| }, | ||
| } | ||
|
|
||
| module.exports = config |
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,4 +7,9 @@ module.exports = { | |
| }, | ||
| ], | ||
| }, | ||
| experimental: { | ||
| instantInsights: { | ||
| validationLevel: 'manual-warning', | ||
| }, | ||
| }, | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.