diff --git a/crates/next-core/src/next_server/context.rs b/crates/next-core/src/next_server/context.rs index bb308e6cb3153..63a2fa9f23af0 100644 --- a/crates/next-core/src/next_server/context.rs +++ b/crates/next-core/src/next_server/context.rs @@ -1063,8 +1063,7 @@ pub async fn get_server_chunking_context_with_client_assets( builder = builder.source_map_source_type(if next_mode.is_development() { SourceMapSourceType::AbsoluteFileUri } else { - // TODO(lukesandberg): switch to relative once next is compatible. - SourceMapSourceType::TurbopackUri + SourceMapSourceType::RelativeUri }); if next_mode.is_production() { builder = builder @@ -1149,8 +1148,7 @@ pub async fn get_server_chunking_context( builder = builder.source_map_source_type(SourceMapSourceType::AbsoluteFileUri); } else { builder = builder - // TODO(lukesandberg): switch to relative once next is compatible. - .source_map_source_type(SourceMapSourceType::TurbopackUri) + .source_map_source_type(SourceMapSourceType::RelativeUri) .chunking_config( Vc::::default().to_resolved().await?, ChunkingConfig { diff --git a/packages/next/src/server/patch-error-inspect.ts b/packages/next/src/server/patch-error-inspect.ts index e9a587a8b6e67..e3a107a6a4aba 100644 --- a/packages/next/src/server/patch-error-inspect.ts +++ b/packages/next/src/server/patch-error-inspect.ts @@ -196,9 +196,16 @@ function getSourcemappedFrameIfPossible( } sourceMapPayload = maybeSourceMapPayload try { + // Pass the source map URL as the second parameter so that the consumer + // can resolve relative paths in the source map's `sources` array. + // This is a guess! Turbopack places .map files as siblings to the chunks so this is sufficient to compute + // relative paths but is actually wrong (the chunk and sourcemap have different content hashes). + // We are using the node API to read the sourcemap and it doesn't give us access to the URI. + const sourceMapURL = sourceURL + '.map' sourceMapConsumer = new SyncSourceMapConsumer( - // @ts-expect-error -- Module.SourceMap['version'] is number but SyncSourceMapConsumer wants a string - sourceMapPayload + sourceMapPayload, + // @ts-expect-error: our typings don't include this parameter but it is here. + sourceMapURL ) } catch (cause) { // We should not log an actual error instance here because that will re-enter 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 5465b70fbeaf3..db6cf5b368083 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 @@ -539,7 +539,7 @@ describe('Cache Components Errors', () => { if (isDebugPrerender) { expect(output).toMatchInlineSnapshot(` "Error: Route "/dynamic-root": Uncached data was accessed outside of . This delays the entire page from rendering, resulting in a slow user experience. Learn more: https://nextjs.org/docs/messages/blocking-route - at IndirectionTwo (bundler:///app/dynamic-root/indirection.tsx:7:34) + at IndirectionTwo (app/dynamic-root/indirection.tsx:7:34) at main () at body () at html () @@ -564,7 +564,7 @@ describe('Cache Components Errors', () => { } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/dynamic-root": Uncached data was accessed outside of . This delays the entire page from rendering, resulting in a slow user experience. Learn more: https://nextjs.org/docs/messages/blocking-route - at a (bundler:///app/dynamic-root/indirection.tsx:7:34) + at a (app/dynamic-root/indirection.tsx:7:34) at main () at body () at html () @@ -593,7 +593,7 @@ describe('Cache Components Errors', () => { if (isDebugPrerender) { expect(output).toMatchInlineSnapshot(` "Error: Route "/dynamic-root": Uncached data was accessed outside of . This delays the entire page from rendering, resulting in a slow user experience. Learn more: https://nextjs.org/docs/messages/blocking-route - at IndirectionTwo (bundler:///app/dynamic-root/indirection.tsx:7:34) + at IndirectionTwo (webpack:///app/dynamic-root/indirection.tsx:7:34) at 5 | } 6 | @@ -745,9 +745,27 @@ describe('Cache Components Errors', () => { ) if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + 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 RandomReadingComponent (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 - at RandomReadingComponent (bundler:///app/sync-random-with-fallback/page.tsx:37:23) + at RandomReadingComponent (webpack:///app/sync-random-with-fallback/page.tsx:37:23) 35 | use(new Promise((r) => process.nextTick(r))) 36 | } > 37 | const random = Math.random() @@ -761,11 +779,12 @@ describe('Cache Components Errors', () => { > Export encountered errors on following paths: /sync-random-with-fallback/page: /sync-random-with-fallback" `) + } } 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) + at a (app/sync-random-with-fallback/page.tsx:37:23) 35 | use(new Promise((r) => process.nextTick(r))) 36 | } > 37 | const random = Math.random() @@ -837,10 +856,29 @@ describe('Cache Components Errors', () => { ) if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + 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 getRandomNumber (app/sync-random-without-fallback/page.tsx:32:15) + at RandomReadingComponent (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 - at getRandomNumber (bundler:///app/sync-random-without-fallback/page.tsx:32:15) - at RandomReadingComponent (bundler:///app/sync-random-without-fallback/page.tsx:40:18) + at getRandomNumber (webpack:///app/sync-random-without-fallback/page.tsx:32:15) + at RandomReadingComponent (webpack:///app/sync-random-without-fallback/page.tsx:40:18) 30 | 31 | function getRandomNumber() { > 32 | return Math.random() @@ -854,11 +892,12 @@ describe('Cache Components Errors', () => { > Export encountered errors on following paths: /sync-random-without-fallback/page: /sync-random-without-fallback" `) + } } 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) + at a (app/sync-random-without-fallback/page.tsx:32:15) 30 | 31 | function getRandomNumber() { > 32 | return Math.random() @@ -1075,10 +1114,30 @@ describe('Cache Components Errors', () => { ) if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + 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 + at CookiesReadingComponent (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 TypeError: ().get is not a function - at CookiesReadingComponent (bundler:///app/sync-cookies/page.tsx:18:36) + at CookiesReadingComponent (webpack:///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 @@ -1093,12 +1152,13 @@ describe('Cache Components Errors', () => { > Export encountered errors on following paths: /sync-cookies/page: /sync-cookies" `) + } } 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 - at a (bundler:///app/sync-cookies/page.tsx:18:36) + at a (app/sync-cookies/page.tsx:18:36) at b () 16 | async function CookiesReadingComponent() { 17 | // Cast to any as we removed UnsafeUnwrapped types, but still need to test with the sync access @@ -1390,10 +1450,30 @@ describe('Cache Components Errors', () => { ) if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + 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 + at HeadersReadingComponent (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 TypeError: ().get is not a function - at HeadersReadingComponent (bundler:///app/sync-headers/page.tsx:18:40) + at HeadersReadingComponent (webpack:///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 @@ -1408,12 +1488,13 @@ describe('Cache Components Errors', () => { > Export encountered errors on following paths: /sync-headers/page: /sync-headers" `) + } } 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 - at a (bundler:///app/sync-headers/page.tsx:18:40) + at a (app/sync-headers/page.tsx:18:40) at b () 16 | async function HeadersReadingComponent() { 17 | // Cast to any as we removed UnsafeUnwrapped types, but still need to test with the sync access @@ -1678,9 +1759,10 @@ describe('Cache Components Errors', () => { ) if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + 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 SyncIO (bundler:///app/sync-attribution/guarded-async-unguarded-clientsync/client.tsx:5:16) + at SyncIO (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() @@ -1694,11 +1776,29 @@ describe('Cache Components Errors', () => { > 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 + at SyncIO (webpack:///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 { 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) + at a (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() @@ -1924,9 +2024,10 @@ describe('Cache Components Errors', () => { ) if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + 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 SyncIO (bundler:///app/sync-attribution/unguarded-async-unguarded-clientsync/client.tsx:5:16) + at SyncIO (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() @@ -1940,11 +2041,29 @@ describe('Cache Components Errors', () => { > 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 + at SyncIO (webpack:///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 { 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) + at a (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() @@ -2014,7 +2133,7 @@ describe('Cache Components Errors', () => { if (isDebugPrerender) { expect(output).toMatchInlineSnapshot(` "Error: 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 - at CookiesReadingComponent (bundler:///app/use-cache-cookies/page.tsx:22:18) + at CookiesReadingComponent (app/use-cache-cookies/page.tsx:22:18) 20 | // in userland. 21 | try { > 22 | await cookies() @@ -2031,7 +2150,7 @@ describe('Cache Components Errors', () => { } else { expect(output).toMatchInlineSnapshot(` "Error: 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 - at (bundler:///app/use-cache-cookies/page.tsx:22:11) + at (app/use-cache-cookies/page.tsx:22:11) 20 | // in userland. 21 | try { > 22 | await cookies() @@ -2050,8 +2169,8 @@ describe('Cache Components Errors', () => { if (isDebugPrerender) { expect(output).toMatchInlineSnapshot(` "Error: 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 - at CookiesReadingComponent (bundler:///app/use-cache-cookies/page.tsx:22:18) - at (bundler:///) + at CookiesReadingComponent (webpack:///app/use-cache-cookies/page.tsx:22:18) + at (webpack:///) 20 | // in userland. 21 | try { > 22 | await cookies() @@ -2118,9 +2237,27 @@ describe('Cache Components Errors', () => { ) if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + 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 DraftModeEnablingComponent (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 - at DraftModeEnablingComponent (bundler:///app/use-cache-draft-mode/page.tsx:20:26) + at DraftModeEnablingComponent (webpack:///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() @@ -2134,11 +2271,12 @@ describe('Cache Components Errors', () => { > Export encountered errors on following paths: /use-cache-draft-mode/page: /use-cache-draft-mode" `) + } } 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) + at (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() @@ -2206,7 +2344,7 @@ describe('Cache Components Errors', () => { if (isDebugPrerender) { expect(output).toMatchInlineSnapshot(` "Error: 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 - at HeadersReadingComponent (bundler:///app/use-cache-headers/page.tsx:21:18) + at HeadersReadingComponent (app/use-cache-headers/page.tsx:21:18) 19 | // to ensure that this error is shown even when it's caught in userland. 20 | try { > 21 | await headers() @@ -2223,7 +2361,7 @@ describe('Cache Components Errors', () => { } else { expect(output).toMatchInlineSnapshot(` "Error: 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 - at (bundler:///app/use-cache-headers/page.tsx:21:11) + at (app/use-cache-headers/page.tsx:21:11) 19 | // to ensure that this error is shown even when it's caught in userland. 20 | try { > 21 | await headers() @@ -2242,8 +2380,8 @@ describe('Cache Components Errors', () => { if (isDebugPrerender) { expect(output).toMatchInlineSnapshot(` "Error: 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 - at HeadersReadingComponent (bundler:///app/use-cache-headers/page.tsx:21:18) - at (bundler:///) + at HeadersReadingComponent (webpack:///app/use-cache-headers/page.tsx:21:18) + at (webpack:///) 19 | // to ensure that this error is shown even when it's caught in userland. 20 | try { > 21 | await headers() @@ -2685,10 +2823,11 @@ describe('Cache Components Errors', () => { ) if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + if (isTurbopack) { + expect(output).toMatchInlineSnapshot(` "Error: "use cache: private" must not be used within \`unstable_cache()\`. - at (bundler:///app/use-cache-private-in-unstable-cache/page.tsx:21:38) - at async ComponentWithCachedData (bundler:///app/use-cache-private-in-unstable-cache/page.tsx:16:16) + at (app/use-cache-private-in-unstable-cache/page.tsx:21:38) + at async ComponentWithCachedData (app/use-cache-private-in-unstable-cache/page.tsx:16:16) 19 | } 20 | > 21 | const getCachedData = unstable_cache(async () => { @@ -2702,12 +2841,31 @@ 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 (webpack:///app/use-cache-private-in-unstable-cache/page.tsx:21:38) + at async ComponentWithCachedData (webpack:///app/use-cache-private-in-unstable-cache/page.tsx:16:16) + 19 | } + 20 | + > 21 | const getCachedData = unstable_cache(async () => { + | ^ + 22 | 'use cache: private' + 23 | + 24 | return fetch('https://next-data-api-endpoint.vercel.app/api/random').then( + 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-private-in-unstable-cache" in your browser to investigate the error. + Error occurred prerendering page "/use-cache-private-in-unstable-cache". Read more: https://nextjs.org/docs/messages/prerender-error + + > Export encountered errors on following paths: + /use-cache-private-in-unstable-cache/page: /use-cache-private-in-unstable-cache" + `) + } } else { if (isTurbopack) { expect(output).toMatchInlineSnapshot(` "Error: "use cache: private" must not be used within \`unstable_cache()\`. - at (bundler:///app/use-cache-private-in-unstable-cache/page.tsx:21:38) - at async h (bundler:///app/use-cache-private-in-unstable-cache/page.tsx:16:16) + at (app/use-cache-private-in-unstable-cache/page.tsx:21:38) + at async h (app/use-cache-private-in-unstable-cache/page.tsx:16:16) 19 | } 20 | > 21 | const getCachedData = unstable_cache(async () => { @@ -2776,9 +2934,10 @@ describe('Cache Components Errors', () => { // TODO: Ideally, the error should only be shown once. if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + if (isTurbopack) { + 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 Private (bundler:///app/use-cache-private-in-use-cache/page.tsx:15:1) + at Private (app/use-cache-private-in-use-cache/page.tsx:15:1) at stringify () 13 | } 14 | @@ -2788,7 +2947,35 @@ describe('Cache Components Errors', () => { 17 | 18 | return

Private

Error: "use cache: private" must not be used within "use cache". It can only be nested inside of another "use cache: private". - at Private (bundler:///app/use-cache-private-in-use-cache/page.tsx:15:1) + at Private (app/use-cache-private-in-use-cache/page.tsx:15:1) + at stringify () + 13 | } + 14 | + > 15 | async function Private() { + | ^ + 16 | 'use cache: private' + 17 | + 18 | return

Private

+ 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-private-in-use-cache" in your browser to investigate the error. + Error occurred prerendering page "/use-cache-private-in-use-cache". Read more: https://nextjs.org/docs/messages/prerender-error + + > 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 Private (webpack:///app/use-cache-private-in-use-cache/page.tsx:15:1) + at stringify () + 13 | } + 14 | + > 15 | async function Private() { + | ^ + 16 | 'use cache: private' + 17 | + 18 | return

Private

+ Error: "use cache: private" must not be used within "use cache". It can only be nested inside of another "use cache: private". + at Private (webpack:///app/use-cache-private-in-use-cache/page.tsx:15:1) at stringify () 13 | } 14 | @@ -2807,7 +2994,7 @@ describe('Cache Components Errors', () => { if (isTurbopack) { 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 (bundler:///app/use-cache-private-in-use-cache/page.tsx:15:1) + at (app/use-cache-private-in-use-cache/page.tsx:15:1) at a () 13 | } 14 | @@ -2817,7 +3004,7 @@ describe('Cache Components Errors', () => { 17 | 18 | return

Private

Error: "use cache: private" must not be used within "use cache". It can only be nested inside of another "use cache: private". - at (bundler:///app/use-cache-private-in-use-cache/page.tsx:15:1) + at (app/use-cache-private-in-use-cache/page.tsx:15:1) at b () 13 | } 14 | @@ -3063,9 +3250,10 @@ describe('Cache Components Errors', () => { ) if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + 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 DateReadingComponent (bundler:///app/sync-io-current-time/date/page.tsx:19:16) + at DateReadingComponent (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()}
@@ -3078,11 +3266,28 @@ describe('Cache Components Errors', () => { > 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 + at DateReadingComponent (webpack:///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 { 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) + at a (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()}
@@ -3148,9 +3353,10 @@ describe('Cache Components Errors', () => { ) if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + 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 DateReadingComponent (bundler:///app/sync-io-current-time/date-now/page.tsx:19:21) + at DateReadingComponent (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()}
@@ -3163,11 +3369,28 @@ describe('Cache Components Errors', () => { > 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 + at DateReadingComponent (webpack:///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 { 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) + at a (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()}
@@ -3233,9 +3456,10 @@ describe('Cache Components Errors', () => { ) if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + 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 DateReadingComponent (bundler:///app/sync-io-current-time/new-date/page.tsx:19:16) + at DateReadingComponent (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()}
@@ -3248,11 +3472,28 @@ describe('Cache Components Errors', () => { > 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 + at DateReadingComponent (webpack:///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 { 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) + at a (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()}
@@ -3318,9 +3559,10 @@ describe('Cache Components Errors', () => { ) if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + 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 SyncIOComponent (bundler:///app/sync-io-random/math-random/page.tsx:19:21) + at SyncIOComponent (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()}
@@ -3333,11 +3575,28 @@ describe('Cache Components Errors', () => { > 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 + at SyncIOComponent (webpack:///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 { 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) + at a (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()}
@@ -3403,9 +3662,10 @@ describe('Cache Components Errors', () => { ) if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + 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 SyncIOComponent (bundler:///app/sync-io-web-crypto/get-random-value/page.tsx:20:10) + at SyncIOComponent (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) @@ -3419,11 +3679,29 @@ 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 { + 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 (webpack:///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 { 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) + at a (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) @@ -3490,9 +3768,10 @@ describe('Cache Components Errors', () => { ) if (isDebugPrerender) { - expect(output).toMatchInlineSnapshot(` + 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 SyncIOComponent (bundler:///app/sync-io-web-crypto/random-uuid/page.tsx:19:23) + at SyncIOComponent (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()}
@@ -3505,11 +3784,28 @@ describe('Cache Components Errors', () => { > 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 + at SyncIOComponent (webpack:///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 { 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) + at a (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()}
@@ -3596,7 +3892,7 @@ describe('Cache Components Errors', () => { if (isDebugPrerender) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/generate-key-pair-sync" used \`require('node:crypto').generateKeyPairSync(...)\` 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-node-crypto/generate-key-pair-sync/page.tsx:20:24) + at SyncIOComponent (app/sync-io-node-crypto/generate-key-pair-sync/page.tsx:20:24) 18 | async function SyncIOComponent() { 19 | await new Promise((r) => process.nextTick(r)) > 20 | const first = crypto.generateKeyPairSync('rsa', keyGenOptions) @@ -3613,7 +3909,7 @@ describe('Cache Components Errors', () => { } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/generate-key-pair-sync" used \`require('node:crypto').generateKeyPairSync(...)\` 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-node-crypto/generate-key-pair-sync/page.tsx:20:24) + at a (app/sync-io-node-crypto/generate-key-pair-sync/page.tsx:20:24) 18 | async function SyncIOComponent() { 19 | await new Promise((r) => process.nextTick(r)) > 20 | const first = crypto.generateKeyPairSync('rsa', keyGenOptions) @@ -3632,7 +3928,7 @@ describe('Cache Components Errors', () => { if (isDebugPrerender) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/generate-key-pair-sync" used \`require('node:crypto').generateKeyPairSync(...)\` 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-node-crypto/generate-key-pair-sync/page.tsx:20:17) + at SyncIOComponent (webpack:///app/sync-io-node-crypto/generate-key-pair-sync/page.tsx:20:17) 18 | async function SyncIOComponent() { 19 | await new Promise((r) => process.nextTick(r)) > 20 | const first = crypto.generateKeyPairSync('rsa', keyGenOptions) @@ -3720,7 +4016,7 @@ describe('Cache Components Errors', () => { if (isDebugPrerender) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/generate-key-sync" used \`require('node:crypto').generateKeySync(...)\` 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-node-crypto/generate-key-sync/page.tsx:21:6) + at SyncIOComponent (app/sync-io-node-crypto/generate-key-sync/page.tsx:21:6) 19 | await new Promise((r) => process.nextTick(r)) 20 | const first = crypto > 21 | .generateKeySync('hmac', { @@ -3737,7 +4033,7 @@ describe('Cache Components Errors', () => { } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/generate-key-sync" used \`require('node:crypto').generateKeySync(...)\` 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-node-crypto/generate-key-sync/page.tsx:21:6) + at a (app/sync-io-node-crypto/generate-key-sync/page.tsx:21:6) 19 | await new Promise((r) => process.nextTick(r)) 20 | const first = crypto > 21 | .generateKeySync('hmac', { @@ -3756,7 +4052,7 @@ describe('Cache Components Errors', () => { if (isDebugPrerender) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/generate-key-sync" used \`require('node:crypto').generateKeySync(...)\` 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-node-crypto/generate-key-sync/page.tsx:20:17) + at SyncIOComponent (webpack:///app/sync-io-node-crypto/generate-key-sync/page.tsx:20:17) 18 | async function SyncIOComponent() { 19 | await new Promise((r) => process.nextTick(r)) > 20 | const first = crypto @@ -3844,7 +4140,7 @@ describe('Cache Components Errors', () => { if (isDebugPrerender) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/generate-prime-sync" used \`require('node:crypto').generatePrimeSync(...)\` 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-node-crypto/generate-prime-sync/page.tsx:20:39) + at SyncIOComponent (app/sync-io-node-crypto/generate-prime-sync/page.tsx:20:39) 18 | async function SyncIOComponent() { 19 | await new Promise((r) => process.nextTick(r)) > 20 | const first = new Uint8Array(crypto.generatePrimeSync(128)) @@ -3861,7 +4157,7 @@ describe('Cache Components Errors', () => { } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/generate-prime-sync" used \`require('node:crypto').generatePrimeSync(...)\` 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-node-crypto/generate-prime-sync/page.tsx:20:39) + at a (app/sync-io-node-crypto/generate-prime-sync/page.tsx:20:39) 18 | async function SyncIOComponent() { 19 | await new Promise((r) => process.nextTick(r)) > 20 | const first = new Uint8Array(crypto.generatePrimeSync(128)) @@ -3880,7 +4176,7 @@ describe('Cache Components Errors', () => { if (isDebugPrerender) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/generate-prime-sync" used \`require('node:crypto').generatePrimeSync(...)\` 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-node-crypto/generate-prime-sync/page.tsx:20:32) + at SyncIOComponent (webpack:///app/sync-io-node-crypto/generate-prime-sync/page.tsx:20:32) 18 | async function SyncIOComponent() { 19 | await new Promise((r) => process.nextTick(r)) > 20 | const first = new Uint8Array(crypto.generatePrimeSync(128)) @@ -3968,7 +4264,7 @@ describe('Cache Components Errors', () => { if (isDebugPrerender) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/get-random-values" 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-node-crypto/get-random-values/page.tsx:21:10) + at SyncIOComponent (app/sync-io-node-crypto/get-random-values/page.tsx:21:10) 19 | await new Promise((r) => process.nextTick(r)) 20 | const first = new Uint8Array(8) > 21 | crypto.getRandomValues(first) @@ -3985,7 +4281,7 @@ describe('Cache Components Errors', () => { } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/get-random-values" 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-node-crypto/get-random-values/page.tsx:21:10) + at a (app/sync-io-node-crypto/get-random-values/page.tsx:21:10) 19 | await new Promise((r) => process.nextTick(r)) 20 | const first = new Uint8Array(8) > 21 | crypto.getRandomValues(first) @@ -4004,7 +4300,7 @@ describe('Cache Components Errors', () => { if (isDebugPrerender) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/get-random-values" 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-node-crypto/get-random-values/page.tsx:21:3) + at SyncIOComponent (webpack:///app/sync-io-node-crypto/get-random-values/page.tsx:21:3) 19 | await new Promise((r) => process.nextTick(r)) 20 | const first = new Uint8Array(8) > 21 | crypto.getRandomValues(first) @@ -4092,7 +4388,7 @@ describe('Cache Components Errors', () => { if (isDebugPrerender) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/random-bytes" used \`require('node:crypto').randomBytes(size)\` 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-node-crypto/random-bytes/page.tsx:20:24) + at SyncIOComponent (app/sync-io-node-crypto/random-bytes/page.tsx:20:24) 18 | async function SyncIOComponent() { 19 | await new Promise((r) => process.nextTick(r)) > 20 | const first = crypto.randomBytes(8) @@ -4109,7 +4405,7 @@ describe('Cache Components Errors', () => { } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/random-bytes" used \`require('node:crypto').randomBytes(size)\` 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-node-crypto/random-bytes/page.tsx:20:24) + at a (app/sync-io-node-crypto/random-bytes/page.tsx:20:24) 18 | async function SyncIOComponent() { 19 | await new Promise((r) => process.nextTick(r)) > 20 | const first = crypto.randomBytes(8) @@ -4128,7 +4424,7 @@ describe('Cache Components Errors', () => { if (isDebugPrerender) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/random-bytes" used \`require('node:crypto').randomBytes(size)\` 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-node-crypto/random-bytes/page.tsx:20:17) + at SyncIOComponent (webpack:///app/sync-io-node-crypto/random-bytes/page.tsx:20:17) 18 | async function SyncIOComponent() { 19 | await new Promise((r) => process.nextTick(r)) > 20 | const first = crypto.randomBytes(8) @@ -4216,7 +4512,7 @@ describe('Cache Components Errors', () => { if (isDebugPrerender) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/random-fill-sync" used \`require('node:crypto').randomFillSync(...)\` 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-node-crypto/random-fill-sync/page.tsx:21:10) + at SyncIOComponent (app/sync-io-node-crypto/random-fill-sync/page.tsx:21:10) 19 | await new Promise((r) => process.nextTick(r)) 20 | const first = new Uint8Array(16) > 21 | crypto.randomFillSync(first, 4, 8) @@ -4233,7 +4529,7 @@ describe('Cache Components Errors', () => { } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/random-fill-sync" used \`require('node:crypto').randomFillSync(...)\` 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-node-crypto/random-fill-sync/page.tsx:21:10) + at a (app/sync-io-node-crypto/random-fill-sync/page.tsx:21:10) 19 | await new Promise((r) => process.nextTick(r)) 20 | const first = new Uint8Array(16) > 21 | crypto.randomFillSync(first, 4, 8) @@ -4252,7 +4548,7 @@ describe('Cache Components Errors', () => { if (isDebugPrerender) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/random-fill-sync" used \`require('node:crypto').randomFillSync(...)\` 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-node-crypto/random-fill-sync/page.tsx:21:3) + at SyncIOComponent (webpack:///app/sync-io-node-crypto/random-fill-sync/page.tsx:21:3) 19 | await new Promise((r) => process.nextTick(r)) 20 | const first = new Uint8Array(16) > 21 | crypto.randomFillSync(first, 4, 8) @@ -4340,7 +4636,7 @@ describe('Cache Components Errors', () => { if (isDebugPrerender) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/random-int-between" used \`require('node:crypto').randomInt(min, max)\` 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-node-crypto/random-int-between/page.tsx:20:24) + at SyncIOComponent (app/sync-io-node-crypto/random-int-between/page.tsx:20:24) 18 | async function SyncIOComponent() { 19 | await new Promise((r) => process.nextTick(r)) > 20 | const first = crypto.randomInt(128, 256) @@ -4357,7 +4653,7 @@ describe('Cache Components Errors', () => { } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/random-int-between" used \`require('node:crypto').randomInt(min, max)\` 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-node-crypto/random-int-between/page.tsx:20:24) + at a (app/sync-io-node-crypto/random-int-between/page.tsx:20:24) 18 | async function SyncIOComponent() { 19 | await new Promise((r) => process.nextTick(r)) > 20 | const first = crypto.randomInt(128, 256) @@ -4376,7 +4672,7 @@ describe('Cache Components Errors', () => { if (isDebugPrerender) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/random-int-between" used \`require('node:crypto').randomInt(min, max)\` 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-node-crypto/random-int-between/page.tsx:20:17) + at SyncIOComponent (webpack:///app/sync-io-node-crypto/random-int-between/page.tsx:20:17) 18 | async function SyncIOComponent() { 19 | await new Promise((r) => process.nextTick(r)) > 20 | const first = crypto.randomInt(128, 256) @@ -4464,7 +4760,7 @@ describe('Cache Components Errors', () => { if (isDebugPrerender) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/random-int-up-to" used \`require('node:crypto').randomInt(min, max)\` 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-node-crypto/random-int-up-to/page.tsx:20:24) + at SyncIOComponent (app/sync-io-node-crypto/random-int-up-to/page.tsx:20:24) 18 | async function SyncIOComponent() { 19 | await new Promise((r) => process.nextTick(r)) > 20 | const first = crypto.randomInt(128) @@ -4481,7 +4777,7 @@ describe('Cache Components Errors', () => { } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/random-int-up-to" used \`require('node:crypto').randomInt(min, max)\` 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-node-crypto/random-int-up-to/page.tsx:20:24) + at a (app/sync-io-node-crypto/random-int-up-to/page.tsx:20:24) 18 | async function SyncIOComponent() { 19 | await new Promise((r) => process.nextTick(r)) > 20 | const first = crypto.randomInt(128) @@ -4500,7 +4796,7 @@ describe('Cache Components Errors', () => { if (isDebugPrerender) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/random-int-up-to" used \`require('node:crypto').randomInt(min, max)\` 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-node-crypto/random-int-up-to/page.tsx:20:17) + at SyncIOComponent (webpack:///app/sync-io-node-crypto/random-int-up-to/page.tsx:20:17) 18 | async function SyncIOComponent() { 19 | await new Promise((r) => process.nextTick(r)) > 20 | const first = crypto.randomInt(128) @@ -4588,7 +4884,7 @@ describe('Cache Components Errors', () => { if (isDebugPrerender) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/random-uuid" used \`require('node:crypto').randomUUID()\` 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-node-crypto/random-uuid/page.tsx:20:24) + at SyncIOComponent (app/sync-io-node-crypto/random-uuid/page.tsx:20:24) 18 | async function SyncIOComponent() { 19 | await new Promise((r) => process.nextTick(r)) > 20 | const first = crypto.randomUUID() @@ -4605,7 +4901,7 @@ describe('Cache Components Errors', () => { } else { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/random-uuid" used \`require('node:crypto').randomUUID()\` 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-node-crypto/random-uuid/page.tsx:20:24) + at a (app/sync-io-node-crypto/random-uuid/page.tsx:20:24) 18 | async function SyncIOComponent() { 19 | await new Promise((r) => process.nextTick(r)) > 20 | const first = crypto.randomUUID() @@ -4624,7 +4920,7 @@ describe('Cache Components Errors', () => { if (isDebugPrerender) { expect(output).toMatchInlineSnapshot(` "Error: Route "/sync-io-node-crypto/random-uuid" used \`require('node:crypto').randomUUID()\` 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-node-crypto/random-uuid/page.tsx:20:17) + at SyncIOComponent (webpack:///app/sync-io-node-crypto/random-uuid/page.tsx:20:17) 18 | async function SyncIOComponent() { 19 | await new Promise((r) => process.nextTick(r)) > 20 | const first = crypto.randomUUID() diff --git a/test/e2e/app-dir/cache-components-errors/utils.ts b/test/e2e/app-dir/cache-components-errors/utils.ts index ac7de71eb16cc..01d8cb406c128 100644 --- a/test/e2e/app-dir/cache-components-errors/utils.ts +++ b/test/e2e/app-dir/cache-components-errors/utils.ts @@ -111,9 +111,6 @@ export function getPrerenderOutput( ) .replace(/at \d+ \(/, replaceNumericModuleId) .replace(/digest: '\d+'/, "digest: ''") - // TODO(veil): Bundler protocols should not appear in stack frames. - .replace('webpack:///', 'bundler:///') - .replace('turbopack:///[project]/', 'bundler:///') lines.push(convertModuleFunctionSequenceExpression(line)) } diff --git a/test/e2e/app-dir/server-source-maps/server-source-maps.test.ts b/test/e2e/app-dir/server-source-maps/server-source-maps.test.ts index 3b035b800ae7d..0952f93d40253 100644 --- a/test/e2e/app-dir/server-source-maps/server-source-maps.test.ts +++ b/test/e2e/app-dir/server-source-maps/server-source-maps.test.ts @@ -8,7 +8,6 @@ function normalizeCliOutput(output: string) { stripAnsi(output) // TODO(veil): Should not appear in sourcemapped stackframes. .replaceAll('webpack:///', 'bundler:///') - .replaceAll('turbopack:///[project]/', 'bundler:///') .replaceAll(/at [a-zA-Z] \(/g, 'at (') ) } @@ -56,9 +55,9 @@ describe('app-dir - server source maps', () => { } else { if (isTurbopack) { // TODO(veil): Sourcemap names - // TODO(veil): relative paths + // TODO(veil): relative paths in webpack expect(normalizeCliOutput(next.cliOutput)).toContain( - '(bundler:///app/rsc-error-log/page.js:4:17)' + '(app/rsc-error-log/page.js:4:17)' ) expect(normalizeCliOutput(next.cliOutput)).toContain( '' + @@ -107,10 +106,10 @@ describe('app-dir - server source maps', () => { // TODO(veil): Sourcemap names // TODO(veil): relative paths expect(normalizeCliOutput(next.cliOutput)).toContain( - '(bundler:///app/rsc-error-log-cause/page.js:2:17)' + '(app/rsc-error-log-cause/page.js:2:17)' ) expect(normalizeCliOutput(next.cliOutput)).toContain( - '(bundler:///app/rsc-error-log-cause/page.js:7:17)' + '(app/rsc-error-log-cause/page.js:7:17)' ) expect(normalizeCliOutput(next.cliOutput)).toContain( '' + @@ -231,7 +230,7 @@ describe('app-dir - server source maps', () => { // TODO(veil): Sourcemap names // TODO(veil): relative paths expect(normalizeCliOutput(next.cliOutput)).toContain( - '(bundler:///app/ssr-error-log-ignore-listed/page.js:9:17)' + '(app/ssr-error-log-ignore-listed/page.js:9:17)' ) expect(normalizeCliOutput(next.cliOutput)).toContain( '\n' + @@ -296,7 +295,7 @@ describe('app-dir - server source maps', () => { // TODO(veil): Sourcemap names // TODO(veil): relative paths expect(normalizeCliOutput(next.cliOutput)).toContain( - 'at (bundler:///app/rsc-error-log-ignore-listed/page.js:8:17)' + 'at (app/rsc-error-log-ignore-listed/page.js:8:17)' ) expect(normalizeCliOutput(next.cliOutput)).toContain( '' + @@ -529,7 +528,7 @@ describe('app-dir - server source maps', () => { '' + '\nError: module-evaluation' + // TODO(veil): Turbopack internals. Feel free to update. Tracked in https://linear.app/vercel/issue/NEXT-4362 - '\n at module evaluation (bundler:///app/module-evaluation/module.js:1:22)' + '\n at module evaluation (app/module-evaluation/module.js:1:22)' ) expect(normalizeCliOutput(next.cliOutput)).toContain( '' + diff --git a/test/production/app-dir/build-output-prerender/build-output-prerender.test.ts b/test/production/app-dir/build-output-prerender/build-output-prerender.test.ts index c48db001e3f18..82ff6900fa024 100644 --- a/test/production/app-dir/build-output-prerender/build-output-prerender.test.ts +++ b/test/production/app-dir/build-output-prerender/build-output-prerender.test.ts @@ -69,7 +69,7 @@ describe('build-output-prerender', () => { // TODO(veil): Why is the location incomplete unless we enable --no-mangling? expect(getPrerenderOutput(next.cliOutput)).toMatchInlineSnapshot(` "Error: Route "/client" 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 c (bundler:///app/client/page.tsx:4:28) + at c (app/client/page.tsx:4:28) 2 | 3 | export default function Page() { > 4 | return

Current time: {new Date().toISOString()}

@@ -183,32 +183,62 @@ describe('build-output-prerender', () => { }) it('shows all prerender errors with readable stacks and code frames', async () => { - expect(getPrerenderOutput(next.cliOutput)).toMatchInlineSnapshot(` - "Error: Route "/client" 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 Page (bundler:///app/client/page.tsx:4:28) - 2 | - 3 | export default function Page() { - > 4 | return

Current time: {new Date().toISOString()}

- | ^ - 5 | } - 6 | - To get a more detailed stack trace and pinpoint the issue, start the app in development mode by running \`next dev\`, then open "/client" in your browser to investigate the error. - Error occurred prerendering page "/client". Read more: https://nextjs.org/docs/messages/prerender-error - Error: Route "/server" 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 Page (bundler:///app/server/page.tsx:13:27) - 11 | await cachedDelay() - 12 | - > 13 | return

Random: {Math.random()}

- | ^ - 14 | } - 15 | - To get a more detailed stack trace and pinpoint the issue, start the app in development mode by running \`next dev\`, then open "/server" in your browser to investigate the error. - Error occurred prerendering page "/server". Read more: https://nextjs.org/docs/messages/prerender-error + if (isTurbopack) { + expect(getPrerenderOutput(next.cliOutput)).toMatchInlineSnapshot(` + "Error: Route "/client" 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 Page (app/client/page.tsx:4:28) + 2 | + 3 | export default function Page() { + > 4 | return

Current time: {new Date().toISOString()}

+ | ^ + 5 | } + 6 | + To get a more detailed stack trace and pinpoint the issue, start the app in development mode by running \`next dev\`, then open "/client" in your browser to investigate the error. + Error occurred prerendering page "/client". Read more: https://nextjs.org/docs/messages/prerender-error + Error: Route "/server" 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 Page (app/server/page.tsx:13:27) + 11 | await cachedDelay() + 12 | + > 13 | return

Random: {Math.random()}

+ | ^ + 14 | } + 15 | + To get a more detailed stack trace and pinpoint the issue, start the app in development mode by running \`next dev\`, then open "/server" in your browser to investigate the error. + Error occurred prerendering page "/server". Read more: https://nextjs.org/docs/messages/prerender-error + + > Export encountered errors on following paths: + /client/page: /client + /server/page: /server" + `) + } else { + // TODO(veil): Bundler protocols should not appear in stackframes. + expect(getPrerenderOutput(next.cliOutput)).toMatchInlineSnapshot(` + "Error: Route "/client" 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 Page (webpack:///app/client/page.tsx:4:28) + 2 | + 3 | export default function Page() { + > 4 | return

Current time: {new Date().toISOString()}

+ | ^ + 5 | } + 6 | + To get a more detailed stack trace and pinpoint the issue, start the app in development mode by running \`next dev\`, then open "/client" in your browser to investigate the error. + Error occurred prerendering page "/client". Read more: https://nextjs.org/docs/messages/prerender-error + Error: Route "/server" 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 Page (webpack:///app/server/page.tsx:13:27) + 11 | await cachedDelay() + 12 | + > 13 | return

Random: {Math.random()}

+ | ^ + 14 | } + 15 | + To get a more detailed stack trace and pinpoint the issue, start the app in development mode by running \`next dev\`, then open "/server" in your browser to investigate the error. + Error occurred prerendering page "/server". Read more: https://nextjs.org/docs/messages/prerender-error - > Export encountered errors on following paths: - /client/page: /client - /server/page: /server" - `) + > Export encountered errors on following paths: + /client/page: /client + /server/page: /server" + `) + } }) }) }) @@ -388,11 +418,7 @@ function getPrerenderOutput(cliOutput: string): string { if (foundPrerenderingLine && !line.includes('Generating static pages')) { lines.push( - line - .replace(/at \w+ \(.next[^)]+\)/, 'at x ()') - // TODO(veil): Bundler protocols should not appear in stackframes. - .replace('webpack:///', 'bundler:///') - .replace('turbopack:///[project]/', 'bundler:///') + line.replace(/at \w+ \(.next[^)]+\)/, 'at x ()') ) } }