From 9c906f130db20bc3658c7d1160e0d7b94b06929d Mon Sep 17 00:00:00 2001 From: Hendrik Liebau Date: Wed, 29 Oct 2025 19:55:50 +0100 Subject: [PATCH] [test] Consolidate identical snapshots across different bundlers I noticed that we fixed some of the differences in error stacks and source frames between bundlers, which allows us to consolidate duplicate snapshot tests. To accomplish this, I asked Claude to write an AST-based script to find and deduplicate the affected snapshots. --- .../cache-components-errors.test.ts | 727 +++--------------- 1 file changed, 93 insertions(+), 634 deletions(-) diff --git a/test/e2e/app-dir/cache-components-errors/cache-components-errors.test.ts b/test/e2e/app-dir/cache-components-errors/cache-components-errors.test.ts index 454ec2f8f54a5..24def5ecf06b3 100644 --- a/test/e2e/app-dir/cache-components-errors/cache-components-errors.test.ts +++ b/test/e2e/app-dir/cache-components-errors/cache-components-errors.test.ts @@ -111,38 +111,20 @@ describe('Cache Components Errors', () => { { isMinified: !isDebugPrerender } ) - if (isTurbopack) { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + if (isDebugPrerender) { + expect(output).toMatchInlineSnapshot(` "Route "/dynamic-metadata-static-route" has a \`generateMetadata\` that depends on Request data (\`cookies()\`, etc...) or uncached external data (\`fetch(...)\`, etc...) when the rest of the route does not. See more info here: https://nextjs.org/docs/messages/next-prerender-dynamic-metadata Error occurred prerendering page "/dynamic-metadata-static-route". Read more: https://nextjs.org/docs/messages/prerender-error > Export encountered errors on following paths: /dynamic-metadata-static-route/page: /dynamic-metadata-static-route" `) - } else { - expect(output).toMatchInlineSnapshot(` - "Route "/dynamic-metadata-static-route" has a \`generateMetadata\` that depends on Request data (\`cookies()\`, etc...) or uncached external data (\`fetch(...)\`, etc...) when the rest of the route does not. See more info here: https://nextjs.org/docs/messages/next-prerender-dynamic-metadata - Error occurred prerendering page "/dynamic-metadata-static-route". Read more: https://nextjs.org/docs/messages/prerender-error - Export encountered an error on /dynamic-metadata-static-route/page: /dynamic-metadata-static-route, exiting the build." - `) - } } else { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` - "Route "/dynamic-metadata-static-route" has a \`generateMetadata\` that depends on Request data (\`cookies()\`, etc...) or uncached external data (\`fetch(...)\`, etc...) when the rest of the route does not. See more info here: https://nextjs.org/docs/messages/next-prerender-dynamic-metadata - Error occurred prerendering page "/dynamic-metadata-static-route". Read more: https://nextjs.org/docs/messages/prerender-error - - > Export encountered errors on following paths: - /dynamic-metadata-static-route/page: /dynamic-metadata-static-route" - `) - } else { - expect(output).toMatchInlineSnapshot(` + expect(output).toMatchInlineSnapshot(` "Route "/dynamic-metadata-static-route" has a \`generateMetadata\` that depends on Request data (\`cookies()\`, etc...) or uncached external data (\`fetch(...)\`, etc...) when the rest of the route does not. See more info here: https://nextjs.org/docs/messages/next-prerender-dynamic-metadata Error occurred prerendering page "/dynamic-metadata-static-route". Read more: https://nextjs.org/docs/messages/prerender-error Export encountered an error on /dynamic-metadata-static-route/page: /dynamic-metadata-static-route, exiting the build." `) - } } }) } @@ -307,38 +289,20 @@ describe('Cache Components Errors', () => { { isMinified: !isDebugPrerender } ) - if (isTurbopack) { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + if (isDebugPrerender) { + expect(output).toMatchInlineSnapshot(` "Route "/dynamic-metadata-static-with-suspense" has a \`generateMetadata\` that depends on Request data (\`cookies()\`, etc...) or uncached external data (\`fetch(...)\`, etc...) when the rest of the route does not. See more info here: https://nextjs.org/docs/messages/next-prerender-dynamic-metadata Error occurred prerendering page "/dynamic-metadata-static-with-suspense". Read more: https://nextjs.org/docs/messages/prerender-error > Export encountered errors on following paths: /dynamic-metadata-static-with-suspense/page: /dynamic-metadata-static-with-suspense" `) - } else { - expect(output).toMatchInlineSnapshot(` - "Route "/dynamic-metadata-static-with-suspense" has a \`generateMetadata\` that depends on Request data (\`cookies()\`, etc...) or uncached external data (\`fetch(...)\`, etc...) when the rest of the route does not. See more info here: https://nextjs.org/docs/messages/next-prerender-dynamic-metadata - Error occurred prerendering page "/dynamic-metadata-static-with-suspense". Read more: https://nextjs.org/docs/messages/prerender-error - Export encountered an error on /dynamic-metadata-static-with-suspense/page: /dynamic-metadata-static-with-suspense, exiting the build." - `) - } } else { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` - "Route "/dynamic-metadata-static-with-suspense" has a \`generateMetadata\` that depends on Request data (\`cookies()\`, etc...) or uncached external data (\`fetch(...)\`, etc...) when the rest of the route does not. See more info here: https://nextjs.org/docs/messages/next-prerender-dynamic-metadata - Error occurred prerendering page "/dynamic-metadata-static-with-suspense". Read more: https://nextjs.org/docs/messages/prerender-error - - > Export encountered errors on following paths: - /dynamic-metadata-static-with-suspense/page: /dynamic-metadata-static-with-suspense" - `) - } else { - expect(output).toMatchInlineSnapshot(` + expect(output).toMatchInlineSnapshot(` "Route "/dynamic-metadata-static-with-suspense" has a \`generateMetadata\` that depends on Request data (\`cookies()\`, etc...) or uncached external data (\`fetch(...)\`, etc...) when the rest of the route does not. See more info here: https://nextjs.org/docs/messages/next-prerender-dynamic-metadata Error occurred prerendering page "/dynamic-metadata-static-with-suspense". Read more: https://nextjs.org/docs/messages/prerender-error Export encountered an error on /dynamic-metadata-static-with-suspense/page: /dynamic-metadata-static-with-suspense, exiting the build." `) - } } }) } @@ -401,38 +365,20 @@ describe('Cache Components Errors', () => { { isMinified: !isDebugPrerender } ) - if (isTurbopack) { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + if (isDebugPrerender) { + expect(output).toMatchInlineSnapshot(` "Route "/dynamic-viewport-static-route" has a \`generateViewport\` that depends on Request data (\`cookies()\`, etc...) or uncached external data (\`fetch(...)\`, etc...) without explicitly allowing fully dynamic rendering. See more info here: https://nextjs.org/docs/messages/next-prerender-dynamic-viewport Error occurred prerendering page "/dynamic-viewport-static-route". Read more: https://nextjs.org/docs/messages/prerender-error > Export encountered errors on following paths: /dynamic-viewport-static-route/page: /dynamic-viewport-static-route" `) - } else { - expect(output).toMatchInlineSnapshot(` - "Route "/dynamic-viewport-static-route" has a \`generateViewport\` that depends on Request data (\`cookies()\`, etc...) or uncached external data (\`fetch(...)\`, etc...) without explicitly allowing fully dynamic rendering. See more info here: https://nextjs.org/docs/messages/next-prerender-dynamic-viewport - Error occurred prerendering page "/dynamic-viewport-static-route". Read more: https://nextjs.org/docs/messages/prerender-error - Export encountered an error on /dynamic-viewport-static-route/page: /dynamic-viewport-static-route, exiting the build." - `) - } } else { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` - "Route "/dynamic-viewport-static-route" has a \`generateViewport\` that depends on Request data (\`cookies()\`, etc...) or uncached external data (\`fetch(...)\`, etc...) without explicitly allowing fully dynamic rendering. See more info here: https://nextjs.org/docs/messages/next-prerender-dynamic-viewport - Error occurred prerendering page "/dynamic-viewport-static-route". Read more: https://nextjs.org/docs/messages/prerender-error - - > Export encountered errors on following paths: - /dynamic-viewport-static-route/page: /dynamic-viewport-static-route" - `) - } else { - expect(output).toMatchInlineSnapshot(` + expect(output).toMatchInlineSnapshot(` "Route "/dynamic-viewport-static-route" has a \`generateViewport\` that depends on Request data (\`cookies()\`, etc...) or uncached external data (\`fetch(...)\`, etc...) without explicitly allowing fully dynamic rendering. See more info here: https://nextjs.org/docs/messages/next-prerender-dynamic-viewport Error occurred prerendering page "/dynamic-viewport-static-route". Read more: https://nextjs.org/docs/messages/prerender-error Export encountered an error on /dynamic-viewport-static-route/page: /dynamic-viewport-static-route, exiting the build." `) - } } }) } @@ -470,38 +416,20 @@ describe('Cache Components Errors', () => { { isMinified: !isDebugPrerender } ) - if (isTurbopack) { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + if (isDebugPrerender) { + expect(output).toMatchInlineSnapshot(` "Route "/dynamic-viewport-dynamic-route" has a \`generateViewport\` that depends on Request data (\`cookies()\`, etc...) or uncached external data (\`fetch(...)\`, etc...) without explicitly allowing fully dynamic rendering. See more info here: https://nextjs.org/docs/messages/next-prerender-dynamic-viewport Error occurred prerendering page "/dynamic-viewport-dynamic-route". Read more: https://nextjs.org/docs/messages/prerender-error > Export encountered errors on following paths: /dynamic-viewport-dynamic-route/page: /dynamic-viewport-dynamic-route" `) - } else { - expect(output).toMatchInlineSnapshot(` - "Route "/dynamic-viewport-dynamic-route" has a \`generateViewport\` that depends on Request data (\`cookies()\`, etc...) or uncached external data (\`fetch(...)\`, etc...) without explicitly allowing fully dynamic rendering. See more info here: https://nextjs.org/docs/messages/next-prerender-dynamic-viewport - Error occurred prerendering page "/dynamic-viewport-dynamic-route". Read more: https://nextjs.org/docs/messages/prerender-error - Export encountered an error on /dynamic-viewport-dynamic-route/page: /dynamic-viewport-dynamic-route, exiting the build." - `) - } } else { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` - "Route "/dynamic-viewport-dynamic-route" has a \`generateViewport\` that depends on Request data (\`cookies()\`, etc...) or uncached external data (\`fetch(...)\`, etc...) without explicitly allowing fully dynamic rendering. See more info here: https://nextjs.org/docs/messages/next-prerender-dynamic-viewport - Error occurred prerendering page "/dynamic-viewport-dynamic-route". Read more: https://nextjs.org/docs/messages/prerender-error - - > Export encountered errors on following paths: - /dynamic-viewport-dynamic-route/page: /dynamic-viewport-dynamic-route" - `) - } else { - expect(output).toMatchInlineSnapshot(` + expect(output).toMatchInlineSnapshot(` "Route "/dynamic-viewport-dynamic-route" has a \`generateViewport\` that depends on Request data (\`cookies()\`, etc...) or uncached external data (\`fetch(...)\`, etc...) without explicitly allowing fully dynamic rendering. See more info here: https://nextjs.org/docs/messages/next-prerender-dynamic-viewport Error occurred prerendering page "/dynamic-viewport-dynamic-route". Read more: https://nextjs.org/docs/messages/prerender-error Export encountered an error on /dynamic-viewport-dynamic-route/page: /dynamic-viewport-dynamic-route, exiting the build." `) - } } }) } @@ -533,69 +461,7 @@ describe('Cache Components Errors', () => { it('should show a collapsed redbox with two errors', async () => { const browser = await next.browser(pathname) - if (isTurbopack) { - await expect(browser).toDisplayCollapsedRedbox(` - [ - { - "description": "Uncached data was accessed outside of - - This delays the entire page from rendering, resulting in a slow user experience. Next.js uses this error to ensure your app loads instantly on every navigation. - - To fix this, you can either: - - Wrap the component in a boundary. This allows Next.js to stream its contents to the user as soon as it's ready, without blocking the rest of the app. - - or - - Move the asynchronous await into a Cache Component ("use cache"). This allows Next.js to statically prerender the component as part of the HTML document, so it's instantly visible to the user. - - Note that request-specific information — such as params, cookies, and headers — is not available during static prerendering, so must be wrapped in . - - Learn more: https://nextjs.org/docs/messages/blocking-route", - "environmentLabel": "Server", - "label": "Blocking Route", - "source": "app/dynamic-root/page.tsx (59:26) @ fetchRandom - > 59 | const response = await fetch( - | ^", - "stack": [ - "fetchRandom app/dynamic-root/page.tsx (59:26)", - "FetchingComponent app/dynamic-root/page.tsx (45:56)", - "Page app/dynamic-root/page.tsx (22:9)", - "LogSafely ", - ], - }, - { - "description": "Uncached data was accessed outside of - - This delays the entire page from rendering, resulting in a slow user experience. Next.js uses this error to ensure your app loads instantly on every navigation. - - To fix this, you can either: - - Wrap the component in a boundary. This allows Next.js to stream its contents to the user as soon as it's ready, without blocking the rest of the app. - - or - - Move the asynchronous await into a Cache Component ("use cache"). This allows Next.js to statically prerender the component as part of the HTML document, so it's instantly visible to the user. - - Note that request-specific information — such as params, cookies, and headers — is not available during static prerendering, so must be wrapped in . - - Learn more: https://nextjs.org/docs/messages/blocking-route", - "environmentLabel": "Server", - "label": "Blocking Route", - "source": "app/dynamic-root/page.tsx (59:26) @ fetchRandom - > 59 | const response = await fetch( - | ^", - "stack": [ - "fetchRandom app/dynamic-root/page.tsx (59:26)", - "FetchingComponent app/dynamic-root/page.tsx (45:56)", - "Page app/dynamic-root/page.tsx (27:7)", - "LogSafely ", - ], - }, - ] - `) - } else { - await expect(browser).toDisplayCollapsedRedbox(` + await expect(browser).toDisplayCollapsedRedbox(` [ { "description": "Uncached data was accessed outside of @@ -655,7 +521,6 @@ describe('Cache Components Errors', () => { }, ] `) - } }) } else { it('should error the build if cache components happens in the root (outside a Suspense)', async () => { @@ -879,9 +744,8 @@ describe('Cache Components Errors', () => { { isMinified: !isDebugPrerender } ) - if (isTurbopack) { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + if (isDebugPrerender) { + expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-random-with-fallback" used \`Math.random()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing random values synchronously in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-random at RandomReadingComponent (bundler:///app/sync-random-with-fallback/page.tsx:37:23) 35 | use(new Promise((r) => process.nextTick(r))) @@ -897,7 +761,8 @@ describe('Cache Components Errors', () => { > Export encountered errors on following paths: /sync-random-with-fallback/page: /sync-random-with-fallback" `) - } else { + } else { + if (isTurbopack) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-random-with-fallback" used \`Math.random()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing random values synchronously in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-random at a (bundler:///app/sync-random-with-fallback/page.tsx:37:23) @@ -914,25 +779,6 @@ describe('Cache Components Errors', () => { Error occurred prerendering page "/sync-random-with-fallback". Read more: https://nextjs.org/docs/messages/prerender-error Export encountered an error on /sync-random-with-fallback/page: /sync-random-with-fallback, exiting the build." `) - } - } else { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` - "Error: Route "/sync-random-with-fallback" used \`Math.random()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing random values synchronously in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-random - at RandomReadingComponent (bundler:///app/sync-random-with-fallback/page.tsx:37:23) - 35 | use(new Promise((r) => process.nextTick(r))) - 36 | } - > 37 | const random = Math.random() - | ^ - 38 | return ( - 39 |
- 40 | {random} - To get a more detailed stack trace and pinpoint the issue, start the app in development mode by running \`next dev\`, then open "/sync-random-with-fallback" in your browser to investigate the error. - Error occurred prerendering page "/sync-random-with-fallback". Read more: https://nextjs.org/docs/messages/prerender-error - - > Export encountered errors on following paths: - /sync-random-with-fallback/page: /sync-random-with-fallback" - `) } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-random-with-fallback" used \`Math.random()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing random values synchronously in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-random @@ -990,9 +836,8 @@ describe('Cache Components Errors', () => { { isMinified: !isDebugPrerender } ) - if (isTurbopack) { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + if (isDebugPrerender) { + expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-random-without-fallback" used \`Math.random()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing random values synchronously in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-random at getRandomNumber (bundler:///app/sync-random-without-fallback/page.tsx:32:15) at RandomReadingComponent (bundler:///app/sync-random-without-fallback/page.tsx:40:18) @@ -1009,7 +854,8 @@ describe('Cache Components Errors', () => { > Export encountered errors on following paths: /sync-random-without-fallback/page: /sync-random-without-fallback" `) - } else { + } else { + if (isTurbopack) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-random-without-fallback" used \`Math.random()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing random values synchronously in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-random at a (bundler:///app/sync-random-without-fallback/page.tsx:32:15) @@ -1026,26 +872,6 @@ describe('Cache Components Errors', () => { Error occurred prerendering page "/sync-random-without-fallback". Read more: https://nextjs.org/docs/messages/prerender-error Export encountered an error on /sync-random-without-fallback/page: /sync-random-without-fallback, exiting the build." `) - } - } else { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` - "Error: Route "/sync-random-without-fallback" used \`Math.random()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing random values synchronously in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-random - at getRandomNumber (bundler:///app/sync-random-without-fallback/page.tsx:32:15) - at RandomReadingComponent (bundler:///app/sync-random-without-fallback/page.tsx:40:18) - 30 | - 31 | function getRandomNumber() { - > 32 | return Math.random() - | ^ - 33 | } - 34 | - 35 | function RandomReadingComponent() { - To get a more detailed stack trace and pinpoint the issue, start the app in development mode by running \`next dev\`, then open "/sync-random-without-fallback" in your browser to investigate the error. - Error occurred prerendering page "/sync-random-without-fallback". Read more: https://nextjs.org/docs/messages/prerender-error - - > Export encountered errors on following paths: - /sync-random-without-fallback/page: /sync-random-without-fallback" - `) } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-random-without-fallback" used \`Math.random()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing random values synchronously in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-random @@ -1248,9 +1074,8 @@ describe('Cache Components Errors', () => { { isMinified: !isDebugPrerender } ) - if (isTurbopack) { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + if (isDebugPrerender) { + expect(output).toMatchInlineSnapshot(` "Error occurred prerendering page "/sync-cookies". Read more: https://nextjs.org/docs/messages/prerender-error TypeError: ().get is not a function at CookiesReadingComponent (bundler:///app/sync-cookies/page.tsx:18:36) @@ -1268,7 +1093,8 @@ describe('Cache Components Errors', () => { > Export encountered errors on following paths: /sync-cookies/page: /sync-cookies" `) - } else { + } else { + if (isTurbopack) { expect(output).toMatchInlineSnapshot(` "Error occurred prerendering page "/sync-cookies". Read more: https://nextjs.org/docs/messages/prerender-error TypeError: ().get is not a function @@ -1285,27 +1111,6 @@ describe('Cache Components Errors', () => { } Export encountered an error on /sync-cookies/page: /sync-cookies, exiting the build." `) - } - } else { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` - "Error occurred prerendering page "/sync-cookies". Read more: https://nextjs.org/docs/messages/prerender-error - TypeError: ().get is not a function - at CookiesReadingComponent (bundler:///app/sync-cookies/page.tsx:18:36) - at stringify () - 16 | async function CookiesReadingComponent() { - 17 | // Cast to any as we removed UnsafeUnwrapped types, but still need to test with the sync access - > 18 | const token = (cookies() as any).get('token') - | ^ - 19 | - 20 | return ( - 21 |
{ - digest: '' - } - - > Export encountered errors on following paths: - /sync-cookies/page: /sync-cookies" - `) } else { expect(output).toMatchInlineSnapshot(` "Error occurred prerendering page "/sync-cookies". Read more: https://nextjs.org/docs/messages/prerender-error @@ -1439,22 +1244,7 @@ describe('Cache Components Errors', () => { it('should show a collapsed redbox with a sync access error', async () => { const browser = await next.browser(`${pathname}`) - if (isTurbopack) { - await expect(browser).toDisplayCollapsedRedbox(` - { - "description": "Route "/sync-draft-mode" used \`draftMode().isEnabled\`. \`draftMode()\` returns a Promise and must be unwrapped with \`await\` or \`React.use()\` before accessing its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis", - "environmentLabel": "Prerender", - "label": "Console Error", - "source": "app/sync-draft-mode/page.tsx (24:31) @ DraftModeReadingComponent - > 24 | const isEnabled = (draftMode() as any).isEnabled - | ^", - "stack": [ - "DraftModeReadingComponent app/sync-draft-mode/page.tsx (24:31)", - "Page app/sync-draft-mode/page.tsx (13:7)", - ], - } - `) - } else if (isRspack) { + if (isTurbopack || isRspack) { await expect(browser).toDisplayCollapsedRedbox(` { "description": "Route "/sync-draft-mode" used \`draftMode().isEnabled\`. \`draftMode()\` returns a Promise and must be unwrapped with \`await\` or \`React.use()\` before accessing its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis", @@ -1599,9 +1389,8 @@ describe('Cache Components Errors', () => { { isMinified: !isDebugPrerender } ) - if (isTurbopack) { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + if (isDebugPrerender) { + expect(output).toMatchInlineSnapshot(` "Error occurred prerendering page "/sync-headers". Read more: https://nextjs.org/docs/messages/prerender-error TypeError: ().get is not a function at HeadersReadingComponent (bundler:///app/sync-headers/page.tsx:18:40) @@ -1619,7 +1408,8 @@ describe('Cache Components Errors', () => { > Export encountered errors on following paths: /sync-headers/page: /sync-headers" `) - } else { + } else { + if (isTurbopack) { expect(output).toMatchInlineSnapshot(` "Error occurred prerendering page "/sync-headers". Read more: https://nextjs.org/docs/messages/prerender-error TypeError: ().get is not a function @@ -1636,27 +1426,6 @@ describe('Cache Components Errors', () => { } Export encountered an error on /sync-headers/page: /sync-headers, exiting the build." `) - } - } else { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` - "Error occurred prerendering page "/sync-headers". Read more: https://nextjs.org/docs/messages/prerender-error - TypeError: ().get is not a function - at HeadersReadingComponent (bundler:///app/sync-headers/page.tsx:18:40) - at stringify () - 16 | async function HeadersReadingComponent() { - 17 | // Cast to any as we removed UnsafeUnwrapped types, but still need to test with the sync access - > 18 | const userAgent = (headers() as any).get('user-agent') - | ^ - 19 | return ( - 20 |
- 21 | this component reads the \`user-agent\` header synchronously: {userAgent} { - digest: '' - } - - > Export encountered errors on following paths: - /sync-headers/page: /sync-headers" - `) } else { expect(output).toMatchInlineSnapshot(` "Error occurred prerendering page "/sync-headers". Read more: https://nextjs.org/docs/messages/prerender-error @@ -1788,23 +1557,7 @@ describe('Cache Components Errors', () => { it('should show a collapsed redbox with a sync access error', async () => { const browser = await next.browser(`${pathname}/test`) - if (isTurbopack) { - await expect(browser).toDisplayCollapsedRedbox(` - { - "description": "A param property was accessed directly with \`params.slug\`. \`params\` is a Promise and must be unwrapped with \`React.use()\` before accessing its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis", - "environmentLabel": null, - "label": "Console Error", - "source": "app/sync-client-params/[slug]/page.tsx (20:39) @ ParamsReadingComponent - > 20 | {String(params.slug)} - | ^", - "stack": [ - "ParamsReadingComponent app/sync-client-params/[slug]/page.tsx (20:39)", - "Page app/sync-client-params/[slug]/page.tsx (11:7)", - ], - } - `) - } else { - await expect(browser).toDisplayCollapsedRedbox(` + await expect(browser).toDisplayCollapsedRedbox(` { "description": "A param property was accessed directly with \`params.slug\`. \`params\` is a Promise and must be unwrapped with \`React.use()\` before accessing its properties. Learn more: https://nextjs.org/docs/messages/sync-dynamic-apis", "environmentLabel": null, @@ -1818,7 +1571,6 @@ describe('Cache Components Errors', () => { ], } `) - } }) } }) @@ -1925,9 +1677,8 @@ describe('Cache Components Errors', () => { { isMinified: !isDebugPrerender } ) - if (isTurbopack) { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + if (isDebugPrerender) { + expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-attribution/guarded-async-unguarded-clientsync" used \`new Date()\` inside a Client Component without a Suspense boundary above it. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time-client at SyncIO (bundler:///app/sync-attribution/guarded-async-unguarded-clientsync/client.tsx:5:16) 3 | export function SyncIO() { @@ -1943,7 +1694,8 @@ describe('Cache Components Errors', () => { > Export encountered errors on following paths: /sync-attribution/guarded-async-unguarded-clientsync/page: /sync-attribution/guarded-async-unguarded-clientsync" `) - } else { + } else { + if (isTurbopack) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-attribution/guarded-async-unguarded-clientsync" used \`new Date()\` inside a Client Component without a Suspense boundary above it. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time-client at a (bundler:///app/sync-attribution/guarded-async-unguarded-clientsync/client.tsx:5:16) @@ -1960,25 +1712,6 @@ describe('Cache Components Errors', () => { Error occurred prerendering page "/sync-attribution/guarded-async-unguarded-clientsync". Read more: https://nextjs.org/docs/messages/prerender-error Export encountered an error on /sync-attribution/guarded-async-unguarded-clientsync/page: /sync-attribution/guarded-async-unguarded-clientsync, exiting the build." `) - } - } else { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` - "Error: Route "/sync-attribution/guarded-async-unguarded-clientsync" used \`new Date()\` inside a Client Component without a Suspense boundary above it. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time-client - at SyncIO (bundler:///app/sync-attribution/guarded-async-unguarded-clientsync/client.tsx:5:16) - 3 | export function SyncIO() { - 4 | // This is a sync IO access that should not cause an error - > 5 | const data = new Date().toISOString() - | ^ - 6 | - 7 | return ( - 8 |
- To get a more detailed stack trace and pinpoint the issue, start the app in development mode by running \`next dev\`, then open "/sync-attribution/guarded-async-unguarded-clientsync" in your browser to investigate the error. - Error occurred prerendering page "/sync-attribution/guarded-async-unguarded-clientsync". Read more: https://nextjs.org/docs/messages/prerender-error - - > Export encountered errors on following paths: - /sync-attribution/guarded-async-unguarded-clientsync/page: /sync-attribution/guarded-async-unguarded-clientsync" - `) } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-attribution/guarded-async-unguarded-clientsync" used \`new Date()\` inside a Client Component without a Suspense boundary above it. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time-client @@ -2006,38 +1739,7 @@ describe('Cache Components Errors', () => { it('should show a collapsed redbox error', async () => { const browser = await next.browser(pathname) - if (isTurbopack) { - await expect(browser).toDisplayCollapsedRedbox(` - { - "description": "Uncached data was accessed outside of - - This delays the entire page from rendering, resulting in a slow user experience. Next.js uses this error to ensure your app loads instantly on every navigation. - - To fix this, you can either: - - Wrap the component in a boundary. This allows Next.js to stream its contents to the user as soon as it's ready, without blocking the rest of the app. - - or - - Move the asynchronous await into a Cache Component ("use cache"). This allows Next.js to statically prerender the component as part of the HTML document, so it's instantly visible to the user. - - Note that request-specific information — such as params, cookies, and headers — is not available during static prerendering, so must be wrapped in . - - Learn more: https://nextjs.org/docs/messages/blocking-route", - "environmentLabel": "Server", - "label": "Blocking Route", - "source": "app/sync-attribution/unguarded-async-guarded-clientsync/page.tsx (34:18) @ RequestData - > 34 | ;(await cookies()).get('foo') - | ^", - "stack": [ - "RequestData app/sync-attribution/unguarded-async-guarded-clientsync/page.tsx (34:18)", - "Page app/sync-attribution/unguarded-async-guarded-clientsync/page.tsx (27:9)", - "LogSafely ", - ], - } - `) - } else { - await expect(browser).toDisplayCollapsedRedbox(` + await expect(browser).toDisplayCollapsedRedbox(` { "description": "Uncached data was accessed outside of @@ -2066,7 +1768,6 @@ describe('Cache Components Errors', () => { ], } `) - } }) } else { it('should error the build with a reason related dynamic data', async () => { @@ -2222,9 +1923,8 @@ describe('Cache Components Errors', () => { { isMinified: !isDebugPrerender } ) - if (isTurbopack) { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + if (isDebugPrerender) { + expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-attribution/unguarded-async-unguarded-clientsync" used \`new Date()\` inside a Client Component without a Suspense boundary above it. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time-client at SyncIO (bundler:///app/sync-attribution/unguarded-async-unguarded-clientsync/client.tsx:5:16) 3 | export function SyncIO() { @@ -2240,7 +1940,8 @@ describe('Cache Components Errors', () => { > Export encountered errors on following paths: /sync-attribution/unguarded-async-unguarded-clientsync/page: /sync-attribution/unguarded-async-unguarded-clientsync" `) - } else { + } else { + if (isTurbopack) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-attribution/unguarded-async-unguarded-clientsync" used \`new Date()\` inside a Client Component without a Suspense boundary above it. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time-client at a (bundler:///app/sync-attribution/unguarded-async-unguarded-clientsync/client.tsx:5:16) @@ -2257,25 +1958,6 @@ describe('Cache Components Errors', () => { Error occurred prerendering page "/sync-attribution/unguarded-async-unguarded-clientsync". Read more: https://nextjs.org/docs/messages/prerender-error Export encountered an error on /sync-attribution/unguarded-async-unguarded-clientsync/page: /sync-attribution/unguarded-async-unguarded-clientsync, exiting the build." `) - } - } else { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` - "Error: Route "/sync-attribution/unguarded-async-unguarded-clientsync" used \`new Date()\` inside a Client Component without a Suspense boundary above it. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time-client - at SyncIO (bundler:///app/sync-attribution/unguarded-async-unguarded-clientsync/client.tsx:5:16) - 3 | export function SyncIO() { - 4 | // This is a sync IO access that should not cause an error - > 5 | const data = new Date().toISOString() - | ^ - 6 | - 7 | return ( - 8 |
- To get a more detailed stack trace and pinpoint the issue, start the app in development mode by running \`next dev\`, then open "/sync-attribution/unguarded-async-unguarded-clientsync" in your browser to investigate the error. - Error occurred prerendering page "/sync-attribution/unguarded-async-unguarded-clientsync". Read more: https://nextjs.org/docs/messages/prerender-error - - > Export encountered errors on following paths: - /sync-attribution/unguarded-async-unguarded-clientsync/page: /sync-attribution/unguarded-async-unguarded-clientsync" - `) } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-attribution/unguarded-async-unguarded-clientsync" used \`new Date()\` inside a Client Component without a Suspense boundary above it. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time-client @@ -2301,22 +1983,7 @@ describe('Cache Components Errors', () => { it('should show a redbox error', async () => { const browser = await next.browser(pathname) - if (isTurbopack) { - await expect(browser).toDisplayRedbox(` - { - "description": "Route /use-cache-cookies used \`cookies()\` inside "use cache". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use \`cookies()\` outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache", - "environmentLabel": null, - "label": "Runtime Error", - "source": "app/use-cache-cookies/page.tsx (22:18) @ CookiesReadingComponent - > 22 | await cookies() - | ^", - "stack": [ - "CookiesReadingComponent app/use-cache-cookies/page.tsx (22:18)", - ], - } - `) - } else { - await expect(browser).toDisplayRedbox(` + await expect(browser).toDisplayRedbox(` { "description": "Route /use-cache-cookies used \`cookies()\` inside "use cache". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use \`cookies()\` outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache", "environmentLabel": null, @@ -2329,7 +1996,6 @@ describe('Cache Components Errors', () => { ], } `) - } }) } else { it('should error the build', async () => { @@ -2418,28 +2084,13 @@ describe('Cache Components Errors', () => { }) describe('draftMode', () => { - const pathname = '/use-cache-draft-mode' - - if (isNextDev) { - it('should show a redbox error', async () => { - const browser = await next.browser(pathname) - - if (isTurbopack) { - await expect(browser).toDisplayRedbox(` - { - "description": "Route /use-cache-draft-mode used "draftMode().enable()" inside "use cache". The enabled status of \`draftMode()\` can be read in caches but you must not enable or disable \`draftMode()\` inside a cache. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache", - "environmentLabel": null, - "label": "Runtime Error", - "source": "app/use-cache-draft-mode/page.tsx (20:26) @ DraftModeEnablingComponent - > 20 | ;(await draftMode()).enable() - | ^", - "stack": [ - "DraftModeEnablingComponent app/use-cache-draft-mode/page.tsx (20:26)", - ], - } - `) - } else { - await expect(browser).toDisplayRedbox(` + const pathname = '/use-cache-draft-mode' + + if (isNextDev) { + it('should show a redbox error', async () => { + const browser = await next.browser(pathname) + + await expect(browser).toDisplayRedbox(` { "description": "Route /use-cache-draft-mode used "draftMode().enable()" inside "use cache". The enabled status of \`draftMode()\` can be read in caches but you must not enable or disable \`draftMode()\` inside a cache. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache", "environmentLabel": null, @@ -2452,7 +2103,6 @@ describe('Cache Components Errors', () => { ], } `) - } }) } else { it('should error the build', async () => { @@ -2467,9 +2117,8 @@ describe('Cache Components Errors', () => { { isMinified: !isDebugPrerender } ) - if (isTurbopack) { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + if (isDebugPrerender) { + expect(output).toMatchInlineSnapshot(` "Error: Route /use-cache-draft-mode used "draftMode().enable()" inside "use cache". The enabled status of \`draftMode()\` can be read in caches but you must not enable or disable \`draftMode()\` inside a cache. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache at DraftModeEnablingComponent (bundler:///app/use-cache-draft-mode/page.tsx:20:26) 18 | // here to ensure that this error is shown even when it's caught in userland. @@ -2485,7 +2134,8 @@ describe('Cache Components Errors', () => { > Export encountered errors on following paths: /use-cache-draft-mode/page: /use-cache-draft-mode" `) - } else { + } else { + if (isTurbopack) { expect(output).toMatchInlineSnapshot(` "Error: Route /use-cache-draft-mode used "draftMode().enable()" inside "use cache". The enabled status of \`draftMode()\` can be read in caches but you must not enable or disable \`draftMode()\` inside a cache. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache at (bundler:///app/use-cache-draft-mode/page.tsx:20:26) @@ -2502,25 +2152,6 @@ describe('Cache Components Errors', () => { Error occurred prerendering page "/use-cache-draft-mode". Read more: https://nextjs.org/docs/messages/prerender-error Export encountered an error on /use-cache-draft-mode/page: /use-cache-draft-mode, exiting the build." `) - } - } else { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` - "Error: Route /use-cache-draft-mode used "draftMode().enable()" inside "use cache". The enabled status of \`draftMode()\` can be read in caches but you must not enable or disable \`draftMode()\` inside a cache. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache - at DraftModeEnablingComponent (bundler:///app/use-cache-draft-mode/page.tsx:20:26) - 18 | // here to ensure that this error is shown even when it's caught in userland. - 19 | try { - > 20 | ;(await draftMode()).enable() - | ^ - 21 | } catch {} - 22 | - 23 | return null - To get a more detailed stack trace and pinpoint the issue, start the app in development mode by running \`next dev\`, then open "/use-cache-draft-mode" in your browser to investigate the error. - Error occurred prerendering page "/use-cache-draft-mode". Read more: https://nextjs.org/docs/messages/prerender-error - - > Export encountered errors on following paths: - /use-cache-draft-mode/page: /use-cache-draft-mode" - `) } else { expect(output).toMatchInlineSnapshot(` "Error: Route /use-cache-draft-mode used "draftMode().enable()" inside "use cache". The enabled status of \`draftMode()\` can be read in caches but you must not enable or disable \`draftMode()\` inside a cache. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache @@ -2544,22 +2175,7 @@ describe('Cache Components Errors', () => { it('should show a redbox error', async () => { const browser = await next.browser(pathname) - if (isTurbopack) { - await expect(browser).toDisplayRedbox(` - { - "description": "Route /use-cache-headers used \`headers()\` inside "use cache". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use \`headers()\` outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache", - "environmentLabel": null, - "label": "Runtime Error", - "source": "app/use-cache-headers/page.tsx (21:18) @ HeadersReadingComponent - > 21 | await headers() - | ^", - "stack": [ - "HeadersReadingComponent app/use-cache-headers/page.tsx (21:18)", - ], - } - `) - } else { - await expect(browser).toDisplayRedbox(` + await expect(browser).toDisplayRedbox(` { "description": "Route /use-cache-headers used \`headers()\` inside "use cache". Accessing Dynamic data sources inside a cache scope is not supported. If you need this data inside a cached function use \`headers()\` outside of the cached function and pass the required dynamic data in as an argument. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache", "environmentLabel": null, @@ -2572,7 +2188,6 @@ describe('Cache Components Errors', () => { ], } `) - } }) } else { it('should error the build', async () => { @@ -2910,15 +2525,9 @@ describe('Cache Components Errors', () => { it('should show a redbox error', async () => { const browser = await next.browser('/use-cache-params/foo') - if (isTurbopack) { - await expect(browser).toDisplayCollapsedRedbox( - `"Redbox did not open."` - ) - } else { - await expect(browser).toDisplayCollapsedRedbox( - `"Redbox did not open."` - ) - } + await expect(browser).toDisplayCollapsedRedbox( + `"Redbox did not open."` + ) }) } else { it('should error the build', async () => { @@ -3126,9 +2735,10 @@ describe('Cache Components Errors', () => { Export encountered an error on /use-cache-private-in-unstable-cache/page: /use-cache-private-in-unstable-cache, exiting the build." `) } - } else if (isRspack) { + } else { if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + if (isRspack) { + expect(output).toMatchInlineSnapshot(` "Error: "use cache: private" must not be used within \`unstable_cache()\`. at 0 (bundler:///app/use-cache-private-in-unstable-cache/page.tsx:21:38) at a () @@ -3145,21 +2755,8 @@ describe('Cache Components Errors', () => { > Export encountered errors on following paths: /use-cache-private-in-unstable-cache/page: /use-cache-private-in-unstable-cache" `) - } else { - expect(output).toMatchInlineSnapshot(` - "Error: "use cache: private" must not be used within \`unstable_cache()\`. - at a () - at b () - To get a more detailed stack trace and pinpoint the issue, try one of the following: - - Start the app in development mode by running \`next dev\`, then open "/use-cache-private-in-unstable-cache" in your browser to investigate the error. - - Rerun the production build with \`next build --debug-prerender\` to generate better stack traces. - Error occurred prerendering page "/use-cache-private-in-unstable-cache". Read more: https://nextjs.org/docs/messages/prerender-error - Export encountered an error on /use-cache-private-in-unstable-cache/page: /use-cache-private-in-unstable-cache, exiting the build." - `) - } - } else { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + } else { + expect(output).toMatchInlineSnapshot(` "Error: "use cache: private" must not be used within \`unstable_cache()\`. at 0 (bundler:///app/use-cache-private-in-unstable-cache/page.tsx:21:38) 19 | } @@ -3175,6 +2772,7 @@ describe('Cache Components Errors', () => { > Export encountered errors on following paths: /use-cache-private-in-unstable-cache/page: /use-cache-private-in-unstable-cache" `) + } } else { expect(output).toMatchInlineSnapshot(` "Error: "use cache: private" must not be used within \`unstable_cache()\`. @@ -3317,9 +2915,10 @@ describe('Cache Components Errors', () => { Export encountered an error on /use-cache-private-in-use-cache/page: /use-cache-private-in-use-cache, exiting the build." `) } - } else if (isRspack) { + } else { if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + if (isRspack) { + expect(output).toMatchInlineSnapshot(` "Error: "use cache: private" must not be used within "use cache". It can only be nested inside of another "use cache: private". at 0 (bundler:///app/use-cache-private-in-use-cache/page.tsx:15:1) at a () @@ -3346,24 +2945,8 @@ describe('Cache Components Errors', () => { > Export encountered errors on following paths: /use-cache-private-in-use-cache/page: /use-cache-private-in-use-cache" `) - } else { - expect(output).toMatchInlineSnapshot(` - "Error: "use cache: private" must not be used within "use cache". It can only be nested inside of another "use cache: private". - at a () - at b () - Error: "use cache: private" must not be used within "use cache". It can only be nested inside of another "use cache: private". - at c () - at d () - To get a more detailed stack trace and pinpoint the issue, try one of the following: - - Start the app in development mode by running \`next dev\`, then open "/use-cache-private-in-use-cache" in your browser to investigate the error. - - Rerun the production build with \`next build --debug-prerender\` to generate better stack traces. - Error occurred prerendering page "/use-cache-private-in-use-cache". Read more: https://nextjs.org/docs/messages/prerender-error - Export encountered an error on /use-cache-private-in-use-cache/page: /use-cache-private-in-use-cache, exiting the build." - `) - } - } else { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + } else { + expect(output).toMatchInlineSnapshot(` "Error: "use cache: private" must not be used within "use cache". It can only be nested inside of another "use cache: private". at 0 (bundler:///app/use-cache-private-in-use-cache/page.tsx:15:1) 13 | } @@ -3388,6 +2971,7 @@ describe('Cache Components Errors', () => { > Export encountered errors on following paths: /use-cache-private-in-use-cache/page: /use-cache-private-in-use-cache" `) + } } else { expect(output).toMatchInlineSnapshot(` "Error: "use cache: private" must not be used within "use cache". It can only be nested inside of another "use cache: private". @@ -3544,22 +3128,7 @@ describe('Cache Components Errors', () => { it.skip('should show a redbox error', async () => { const browser = await next.browser('/use-cache-private-connection') - if (isTurbopack) { - await expect(browser).toDisplayCollapsedRedbox(` - { - "description": "Route /use-cache-private-connection used \`connection()\` inside "use cache: private". The \`connection()\` function is used to indicate the subsequent code must only run when there is an actual navigation request, but caches must be able to be produced before a navigation request, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache", - "environmentLabel": null, - "label": "Runtime Error", - "source": "app/use-cache-private-connection/page.tsx (25:21) @ Private - > 25 | await connection() - | ^", - "stack": [ - "Private app/use-cache-private-connection/page.tsx (25:21)", - ], - } - `) - } else { - await expect(browser).toDisplayCollapsedRedbox(` + await expect(browser).toDisplayCollapsedRedbox(` { "description": "Route /use-cache-private-connection used \`connection()\` inside "use cache: private". The \`connection()\` function is used to indicate the subsequent code must only run when there is an actual navigation request, but caches must be able to be produced before a navigation request, so this function is not allowed in this scope. See more info here: https://nextjs.org/docs/messages/next-request-in-use-cache", "environmentLabel": null, @@ -3572,7 +3141,6 @@ describe('Cache Components Errors', () => { ], } `) - } }) } else { // TODO: With prefetch sentinels this should yield a build error. @@ -3633,9 +3201,8 @@ describe('Cache Components Errors', () => { { isMinified: !isDebugPrerender } ) - if (isTurbopack) { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + if (isDebugPrerender) { + expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-current-time/date" used \`Date()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing the current time in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time at DateReadingComponent (bundler:///app/sync-io-current-time/date/page.tsx:19:16) 17 | async function DateReadingComponent() { @@ -3650,7 +3217,8 @@ describe('Cache Components Errors', () => { > Export encountered errors on following paths: /sync-io-current-time/date/page: /sync-io-current-time/date" `) - } else { + } else { + if (isTurbopack) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-current-time/date" used \`Date()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing the current time in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time at a (bundler:///app/sync-io-current-time/date/page.tsx:19:16) @@ -3666,24 +3234,6 @@ describe('Cache Components Errors', () => { Error occurred prerendering page "/sync-io-current-time/date". Read more: https://nextjs.org/docs/messages/prerender-error Export encountered an error on /sync-io-current-time/date/page: /sync-io-current-time/date, exiting the build." `) - } - } else { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` - "Error: Route "/sync-io-current-time/date" used \`Date()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing the current time in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time - at DateReadingComponent (bundler:///app/sync-io-current-time/date/page.tsx:19:16) - 17 | async function DateReadingComponent() { - 18 | await new Promise((r) => process.nextTick(r)) - > 19 | return
{Date()}
- | ^ - 20 | } - 21 | - To get a more detailed stack trace and pinpoint the issue, start the app in development mode by running \`next dev\`, then open "/sync-io-current-time/date" in your browser to investigate the error. - Error occurred prerendering page "/sync-io-current-time/date". Read more: https://nextjs.org/docs/messages/prerender-error - - > Export encountered errors on following paths: - /sync-io-current-time/date/page: /sync-io-current-time/date" - `) } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-current-time/date" used \`Date()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing the current time in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time @@ -3736,9 +3286,8 @@ describe('Cache Components Errors', () => { { isMinified: !isDebugPrerender } ) - if (isTurbopack) { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + if (isDebugPrerender) { + expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-current-time/date-now" used \`Date.now()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing the current time in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time at DateReadingComponent (bundler:///app/sync-io-current-time/date-now/page.tsx:19:21) 17 | async function DateReadingComponent() { @@ -3753,7 +3302,8 @@ describe('Cache Components Errors', () => { > Export encountered errors on following paths: /sync-io-current-time/date-now/page: /sync-io-current-time/date-now" `) - } else { + } else { + if (isTurbopack) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-current-time/date-now" used \`Date.now()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing the current time in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time at a (bundler:///app/sync-io-current-time/date-now/page.tsx:19:21) @@ -3769,24 +3319,6 @@ describe('Cache Components Errors', () => { Error occurred prerendering page "/sync-io-current-time/date-now". Read more: https://nextjs.org/docs/messages/prerender-error Export encountered an error on /sync-io-current-time/date-now/page: /sync-io-current-time/date-now, exiting the build." `) - } - } else { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` - "Error: Route "/sync-io-current-time/date-now" used \`Date.now()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing the current time in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time - at DateReadingComponent (bundler:///app/sync-io-current-time/date-now/page.tsx:19:21) - 17 | async function DateReadingComponent() { - 18 | await new Promise((r) => process.nextTick(r)) - > 19 | return
{Date.now()}
- | ^ - 20 | } - 21 | - To get a more detailed stack trace and pinpoint the issue, start the app in development mode by running \`next dev\`, then open "/sync-io-current-time/date-now" in your browser to investigate the error. - Error occurred prerendering page "/sync-io-current-time/date-now". Read more: https://nextjs.org/docs/messages/prerender-error - - > Export encountered errors on following paths: - /sync-io-current-time/date-now/page: /sync-io-current-time/date-now" - `) } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-current-time/date-now" used \`Date.now()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing the current time in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time @@ -3839,9 +3371,8 @@ describe('Cache Components Errors', () => { { isMinified: !isDebugPrerender } ) - if (isTurbopack) { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + if (isDebugPrerender) { + expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-current-time/new-date" used \`new Date()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing the current time in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time at DateReadingComponent (bundler:///app/sync-io-current-time/new-date/page.tsx:19:16) 17 | async function DateReadingComponent() { @@ -3856,7 +3387,8 @@ describe('Cache Components Errors', () => { > Export encountered errors on following paths: /sync-io-current-time/new-date/page: /sync-io-current-time/new-date" `) - } else { + } else { + if (isTurbopack) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-current-time/new-date" used \`new Date()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing the current time in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time at a (bundler:///app/sync-io-current-time/new-date/page.tsx:19:16) @@ -3872,24 +3404,6 @@ describe('Cache Components Errors', () => { Error occurred prerendering page "/sync-io-current-time/new-date". Read more: https://nextjs.org/docs/messages/prerender-error Export encountered an error on /sync-io-current-time/new-date/page: /sync-io-current-time/new-date, exiting the build." `) - } - } else { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` - "Error: Route "/sync-io-current-time/new-date" used \`new Date()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing the current time in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time - at DateReadingComponent (bundler:///app/sync-io-current-time/new-date/page.tsx:19:16) - 17 | async function DateReadingComponent() { - 18 | await new Promise((r) => process.nextTick(r)) - > 19 | return
{new Date().toString()}
- | ^ - 20 | } - 21 | - To get a more detailed stack trace and pinpoint the issue, start the app in development mode by running \`next dev\`, then open "/sync-io-current-time/new-date" in your browser to investigate the error. - Error occurred prerendering page "/sync-io-current-time/new-date". Read more: https://nextjs.org/docs/messages/prerender-error - - > Export encountered errors on following paths: - /sync-io-current-time/new-date/page: /sync-io-current-time/new-date" - `) } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-current-time/new-date" used \`new Date()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing the current time in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-current-time @@ -3942,9 +3456,8 @@ describe('Cache Components Errors', () => { { isMinified: !isDebugPrerender } ) - if (isTurbopack) { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + if (isDebugPrerender) { + expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-random/math-random" used \`Math.random()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing random values synchronously in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-random at SyncIOComponent (bundler:///app/sync-io-random/math-random/page.tsx:19:21) 17 | async function SyncIOComponent() { @@ -3959,7 +3472,8 @@ describe('Cache Components Errors', () => { > Export encountered errors on following paths: /sync-io-random/math-random/page: /sync-io-random/math-random" `) - } else { + } else { + if (isTurbopack) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-random/math-random" used \`Math.random()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing random values synchronously in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-random at a (bundler:///app/sync-io-random/math-random/page.tsx:19:21) @@ -3975,24 +3489,6 @@ describe('Cache Components Errors', () => { Error occurred prerendering page "/sync-io-random/math-random". Read more: https://nextjs.org/docs/messages/prerender-error Export encountered an error on /sync-io-random/math-random/page: /sync-io-random/math-random, exiting the build." `) - } - } else { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` - "Error: Route "/sync-io-random/math-random" used \`Math.random()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing random values synchronously in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-random - at SyncIOComponent (bundler:///app/sync-io-random/math-random/page.tsx:19:21) - 17 | async function SyncIOComponent() { - 18 | await new Promise((r) => process.nextTick(r)) - > 19 | return
{Math.random()}
- | ^ - 20 | } - 21 | - To get a more detailed stack trace and pinpoint the issue, start the app in development mode by running \`next dev\`, then open "/sync-io-random/math-random" in your browser to investigate the error. - Error occurred prerendering page "/sync-io-random/math-random". Read more: https://nextjs.org/docs/messages/prerender-error - - > Export encountered errors on following paths: - /sync-io-random/math-random/page: /sync-io-random/math-random" - `) } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-random/math-random" used \`Math.random()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing random values synchronously in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-random @@ -4045,9 +3541,8 @@ describe('Cache Components Errors', () => { { isMinified: !isDebugPrerender } ) - if (isTurbopack) { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + if (isDebugPrerender) { + expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-web-crypto/get-random-value" used \`crypto.getRandomValues()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing random cryptographic values synchronously in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-crypto at SyncIOComponent (bundler:///app/sync-io-web-crypto/get-random-value/page.tsx:20:10) 18 | await new Promise((r) => process.nextTick(r)) @@ -4063,7 +3558,8 @@ describe('Cache Components Errors', () => { > Export encountered errors on following paths: /sync-io-web-crypto/get-random-value/page: /sync-io-web-crypto/get-random-value" `) - } else { + } else { + if (isTurbopack) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-web-crypto/get-random-value" used \`crypto.getRandomValues()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing random cryptographic values synchronously in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-crypto at a (bundler:///app/sync-io-web-crypto/get-random-value/page.tsx:20:10) @@ -4080,25 +3576,6 @@ describe('Cache Components Errors', () => { Error occurred prerendering page "/sync-io-web-crypto/get-random-value". Read more: https://nextjs.org/docs/messages/prerender-error Export encountered an error on /sync-io-web-crypto/get-random-value/page: /sync-io-web-crypto/get-random-value, exiting the build." `) - } - } else { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` - "Error: Route "/sync-io-web-crypto/get-random-value" used \`crypto.getRandomValues()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing random cryptographic values synchronously in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-crypto - at SyncIOComponent (bundler:///app/sync-io-web-crypto/get-random-value/page.tsx:20:10) - 18 | await new Promise((r) => process.nextTick(r)) - 19 | const buffer = new Uint8Array(8) - > 20 | crypto.getRandomValues(buffer) - | ^ - 21 | return
{buffer.toString()}
- 22 | } - 23 | - To get a more detailed stack trace and pinpoint the issue, start the app in development mode by running \`next dev\`, then open "/sync-io-web-crypto/get-random-value" in your browser to investigate the error. - Error occurred prerendering page "/sync-io-web-crypto/get-random-value". Read more: https://nextjs.org/docs/messages/prerender-error - - > Export encountered errors on following paths: - /sync-io-web-crypto/get-random-value/page: /sync-io-web-crypto/get-random-value" - `) } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-web-crypto/get-random-value" used \`crypto.getRandomValues()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing random cryptographic values synchronously in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-crypto @@ -4151,9 +3628,8 @@ describe('Cache Components Errors', () => { { isMinified: !isDebugPrerender } ) - if (isTurbopack) { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + if (isDebugPrerender) { + expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-web-crypto/random-uuid" used \`crypto.randomUUID()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing random cryptographic values synchronously in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-crypto at SyncIOComponent (bundler:///app/sync-io-web-crypto/random-uuid/page.tsx:19:23) 17 | async function SyncIOComponent() { @@ -4168,7 +3644,8 @@ describe('Cache Components Errors', () => { > Export encountered errors on following paths: /sync-io-web-crypto/random-uuid/page: /sync-io-web-crypto/random-uuid" `) - } else { + } else { + if (isTurbopack) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-web-crypto/random-uuid" used \`crypto.randomUUID()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing random cryptographic values synchronously in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-crypto at a (bundler:///app/sync-io-web-crypto/random-uuid/page.tsx:19:23) @@ -4184,24 +3661,6 @@ describe('Cache Components Errors', () => { Error occurred prerendering page "/sync-io-web-crypto/random-uuid". Read more: https://nextjs.org/docs/messages/prerender-error Export encountered an error on /sync-io-web-crypto/random-uuid/page: /sync-io-web-crypto/random-uuid, exiting the build." `) - } - } else { - if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` - "Error: Route "/sync-io-web-crypto/random-uuid" used \`crypto.randomUUID()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing random cryptographic values synchronously in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-crypto - at SyncIOComponent (bundler:///app/sync-io-web-crypto/random-uuid/page.tsx:19:23) - 17 | async function SyncIOComponent() { - 18 | await new Promise((r) => process.nextTick(r)) - > 19 | return
{crypto.randomUUID()}
- | ^ - 20 | } - 21 | - To get a more detailed stack trace and pinpoint the issue, start the app in development mode by running \`next dev\`, then open "/sync-io-web-crypto/random-uuid" in your browser to investigate the error. - Error occurred prerendering page "/sync-io-web-crypto/random-uuid". Read more: https://nextjs.org/docs/messages/prerender-error - - > Export encountered errors on following paths: - /sync-io-web-crypto/random-uuid/page: /sync-io-web-crypto/random-uuid" - `) } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-web-crypto/random-uuid" used \`crypto.randomUUID()\` before accessing either uncached data (e.g. \`fetch()\`) or Request data (e.g. \`cookies()\`, \`headers()\`, \`connection()\`, and \`searchParams\`). Accessing random cryptographic values synchronously in a Server Component requires reading one of these data sources first. Alternatively, consider moving this expression into a Client Component or Cache Component. See more info here: https://nextjs.org/docs/messages/next-prerender-crypto