Skip to content

Commit 0b2c3b1

Browse files
authored
[Cache Components] Only validate the shell on SSR render (#82381)
Prior to this change on every navigation we would validate that the initial static shell satisified the rules of cache components. This offers more protection as you edit pages but it slows down navigations and we are already concerned with dev speed and the extra CPU contention can potenially hide or exacerbate other performance characteristics you might notice in dev. So for now we will only validate a page on initial load. This means that if you are trying to debug a page's static shell suitability you will need to refresh the page not just navigate to and from it.
1 parent 2f08176 commit 0b2c3b1

File tree

2 files changed

+10
-27
lines changed

2 files changed

+10
-27
lines changed

packages/next/src/server/app-render/app-render.tsx

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -572,31 +572,6 @@ async function generateDynamicFlightRenderResult(
572572
options
573573
)
574574

575-
if (
576-
// We only want this behavior when running `next dev`
577-
renderOpts.dev &&
578-
// We only want this behavior when we have React's dev builds available
579-
process.env.NODE_ENV === 'development' &&
580-
// We only have a Prerender environment for projects opted into cacheComponents
581-
renderOpts.experimental.cacheComponents
582-
) {
583-
const [resolveValidation, validationOutlet] = createValidationOutlet()
584-
RSCPayload._validation = validationOutlet
585-
586-
const devValidatingFallbackParams =
587-
getRequestMeta(req, 'devValidatingFallbackParams') || null
588-
589-
spawnDynamicValidationInDev(
590-
resolveValidation,
591-
ctx.componentMod.tree,
592-
ctx,
593-
false,
594-
ctx.clientReferenceManifest,
595-
requestStore,
596-
devValidatingFallbackParams
597-
)
598-
}
599-
600575
// For app dir, use the bundled version of Flight server renderer (renderToReadableStream)
601576
// which contains the subset React.
602577
const flightReadableStream = workUnitAsyncStorage.run(

test/development/app-dir/cache-components-dev-errors/cache-components-dev-errors.test.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import stripAnsi from 'strip-ansi'
22
import { nextTestSetup } from 'e2e-utils'
3-
import { assertNoRedbox, hasErrorToast, retry } from 'next-test-utils'
3+
import {
4+
assertNoRedbox,
5+
assertNoErrorToast,
6+
hasErrorToast,
7+
retry,
8+
} from 'next-test-utils'
49
import { createSandbox } from 'development-sandbox'
510
import { outdent } from 'outdent'
611

@@ -32,14 +37,17 @@ describe('Cache Components Dev Errors', () => {
3237
`)
3338
})
3439

35-
it('should show a red box error on client navigations', async () => {
40+
it('should not show a red box error on client navigations', async () => {
3641
const browser = await next.browser('/no-error')
3742

3843
await retry(async () => {
3944
expect(await hasErrorToast(browser)).toBe(false)
4045
})
4146

4247
await browser.elementByCss("[href='/error']").click()
48+
await assertNoErrorToast(browser)
49+
50+
await browser.loadPage(`${next.url}/error`)
4351

4452
// TODO: React should not include the anon stack in the Owner Stack.
4553
await expect(browser).toDisplayCollapsedRedbox(`

0 commit comments

Comments
 (0)