mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
### What? Redesigns the blocking-route error overlay for instant navigation errors with a distinct "Instant" overlay path, visual technique cards, and updated error wording framed around navigation impact. ### Why? The current overlay dumps every possible cause and fix in one block of text. The new design is friendlier — amber "Instant" badge, a short headline framed around navigation, and responsive code snippet cards showing each fix pattern. ### Demo - **Runtime template** (e.g. `cookies()`): https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/26-cookies-ssr-no-instant - **Dynamic template** (e.g. uncached `fetch`): https://error-messages-overhaul-ibsl.labs.vercel.dev/scenario/27-fetch-ssr-no-instant ### How? **Overlay** - New early-return path in `errors.tsx` for `blocking-route` errors without refinement — renders `InstantRuntimeError` with CodeFrame → description → technique cards → CallStack → ErrorCause - `InstantGuidance` component with responsive CSS grid of fix technique cards (3 per variant) - Color-coded cards with colored borders and matching highlight text (blue, purple, red) - "Make route params static" card (runtime only) has a dashed border indicating it's conditional **Build & CLI messages** - Build output messages extracted into `blocking-route-messages.ts` and deduplicated across `dynamic-rendering.ts` - `dynamicOrRuntimeBodyMessage` added for build-time static validation where the specific cause can't be pinpointed — lists all APIs (`fetch(...)`, `cookies()`, `headers()`, `params`, `searchParams`, `connection()`) - `isRuntimeVariant()` replaces the old `includes('cookies()')` heuristic which broke because both templates mention `cookies()` - `logBuildDebugHint()` extracted and shared between `logDisallowedDynamicError` and instant validation — adds "run `next dev`" and "`next build --debug-prerender`" hints to instant validation build output Results: <img width="2094" height="1478" alt="Google Chrome 2026-04-17 16 37 00" src="https://github.com/user-attachments/assets/04f126c5-250c-4e6e-bad0-d6960496cd13" /> <img width="1978" height="1512" alt="Google Chrome 2026-04-17 16 36 37" src="https://github.com/user-attachments/assets/46a502d8-9500-4055-814b-3efb739949db" /> --------- Co-authored-by: Janka Uryga <[email protected]>
77 lines
2.7 KiB
TypeScript
77 lines
2.7 KiB
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
import { waitForNoErrorToast } from 'next-test-utils'
|
|
import { join } from 'node:path'
|
|
|
|
describe('instant validation - opting out of static shells', () => {
|
|
const { next, skipped, isNextDev } = nextTestSetup({
|
|
files: join(__dirname, 'fixtures', 'valid'),
|
|
skipDeployment: true,
|
|
})
|
|
if (skipped) return
|
|
|
|
// NOTE: if something's wrong in build, we'll fail before any tests run.
|
|
// Visiting the pages is mostly just a sanity check.
|
|
|
|
it('does not require a static shell if a root layouts is configured as blocking', async () => {
|
|
const browser = await next.browser('/blocking-root-layout')
|
|
await browser.elementByCss('main')
|
|
if (isNextDev) await waitForNoErrorToast(browser)
|
|
})
|
|
it('does not require a static shell if a layout is configured as blocking', async () => {
|
|
const browser = await next.browser('/blocking-layout')
|
|
await browser.elementByCss('main')
|
|
if (isNextDev) await waitForNoErrorToast(browser)
|
|
})
|
|
it('does not require a static shell if a page is configured as blocking', async () => {
|
|
const browser = await next.browser('/blocking-page')
|
|
await browser.elementByCss('main')
|
|
if (isNextDev) await waitForNoErrorToast(browser)
|
|
})
|
|
})
|
|
|
|
describe('instant validation', () => {
|
|
describe('requires a static shell if a below a static layout page is configured as blocking', () => {
|
|
const { next, skipped, isNextDev } = nextTestSetup({
|
|
files: join(__dirname, 'fixtures', 'invalid-blocking-page-below-static'),
|
|
skipStart: true,
|
|
skipDeployment: true,
|
|
})
|
|
if (skipped) return
|
|
|
|
if (isNextDev) {
|
|
beforeAll(() => next.start())
|
|
it('errors in dev', async () => {
|
|
const browser = await next.browser('/blocking-page-below-static')
|
|
await browser.elementByCss('main')
|
|
await expect(browser).toDisplayCollapsedRedbox(`
|
|
{
|
|
"code": "E1164",
|
|
"description": "Next.js encountered uncached data during the initial render.",
|
|
"environmentLabel": "Server",
|
|
"label": "Instant",
|
|
"source": "app/blocking-page-below-static/page.tsx (6:19) @ Page
|
|
> 6 | await connection()
|
|
| ^",
|
|
"stack": [
|
|
"Page app/blocking-page-below-static/page.tsx (6:19)",
|
|
],
|
|
}
|
|
`)
|
|
})
|
|
} else {
|
|
let didBuildError = false
|
|
beforeAll(async () => {
|
|
try {
|
|
await next.start()
|
|
} catch (err) {
|
|
didBuildError = true
|
|
}
|
|
})
|
|
it('errors during build', () => {
|
|
expect(didBuildError).toBe(true)
|
|
expect(next.cliOutput).toContain('during the initial render')
|
|
})
|
|
}
|
|
})
|
|
})
|