diff --git a/packages/next/pages/_document.tsx b/packages/next/pages/_document.tsx index 3086c431568c..a5e24bed21dc 100644 --- a/packages/next/pages/_document.tsx +++ b/packages/next/pages/_document.tsx @@ -978,7 +978,11 @@ export class NextScript extends Component { if (largePageDataBytes && bytes > largePageDataBytes) { console.warn( - `Warning: data for page "${__NEXT_DATA__.page}" is ${prettyBytes( + `Warning: data for page "${__NEXT_DATA__.page}"${ + __NEXT_DATA__.page === context.dangerousAsPath + ? '' + : ` (path "${context.dangerousAsPath}")` + } is ${prettyBytes( bytes )} which exceeds the threshold of ${prettyBytes( largePageDataBytes diff --git a/test/e2e/prerender.test.ts b/test/e2e/prerender.test.ts index ed06c391e93e..35e4d9acdebd 100644 --- a/test/e2e/prerender.test.ts +++ b/test/e2e/prerender.test.ts @@ -198,6 +198,11 @@ describe('Prerender', () => { initialRevalidateSeconds: 1, srcRoute: '/blocking-fallback-some/[slug]', }, + '/blocking-fallback/lots-of-data': { + dataRoute: `/_next/data/${next.buildId}/blocking-fallback/lots-of-data.json`, + initialRevalidateSeconds: false, + srcRoute: '/blocking-fallback/[slug]', + }, '/blocking-fallback/test-errors-1': { dataRoute: `/_next/data/${next.buildId}/blocking-fallback/test-errors-1.json`, initialRevalidateSeconds: 1, @@ -962,6 +967,11 @@ describe('Prerender', () => { () => next.cliOutput, /Warning: data for page "\/large-page-data" is 256 kB which exceeds the threshold of 128 kB, this amount of data can reduce performance/ ) + await renderViaHTTP(next.url, '/blocking-fallback/lots-of-data') + await check( + () => next.cliOutput, + /Warning: data for page "\/blocking-fallback\/\[slug\]" \(path "\/blocking-fallback\/lots-of-data"\) is 256 kB which exceeds the threshold of 128 kB, this amount of data can reduce performance/ + ) }) if ((global as any).isNextDev) { diff --git a/test/e2e/prerender/pages/blocking-fallback/[slug].js b/test/e2e/prerender/pages/blocking-fallback/[slug].js index cf6aec867a32..af957a3c98f8 100644 --- a/test/e2e/prerender/pages/blocking-fallback/[slug].js +++ b/test/e2e/prerender/pages/blocking-fallback/[slug].js @@ -10,12 +10,23 @@ export async function getStaticPaths() { { params: { slug: 'test-errors-1' }, }, + { + params: { slug: 'lots-of-data' }, + }, ], fallback: 'blocking', } } export async function getStaticProps({ params }) { + if (params.slug === 'lots-of-data') { + return { + props: { + lotsOfData: new Array(256 * 1000).fill('a').join(''), + }, + } + } + if (params.slug.startsWith('test-errors')) { const errorFile = path.join(process.cwd(), 'error.txt') if (fs.existsSync(errorFile)) {