From 0c40739335fcbbe1d084ed16e62ed9be5b30f77c Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Wed, 30 Mar 2022 18:56:40 +0200 Subject: [PATCH 1/3] fix useStatic404 condition --- packages/next/build/index.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/next/build/index.ts b/packages/next/build/index.ts index 098b3757f486..db60484e0745 100644 --- a/packages/next/build/index.ts +++ b/packages/next/build/index.ts @@ -1394,9 +1394,7 @@ export default async function build( // Since custom _app.js can wrap the 404 page we have to opt-out of static optimization if it has getInitialProps // Only export the static 404 when there is no /_error present const useStatic404 = - !hasConcurrentFeatures && - !customAppGetInitialProps && - (!hasNonStaticErrorPage || hasPages404) + !customAppGetInitialProps && (!hasNonStaticErrorPage || hasPages404) if (invalidPages.size > 0) { const err = new Error( From 858358d3a5bbd68f4fbb826447c8976a03433b36 Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Wed, 30 Mar 2022 12:01:31 -0500 Subject: [PATCH 2/3] add static 404 with react 18 test --- test/production/react-18-streaming-ssr/index.test.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/production/react-18-streaming-ssr/index.test.ts b/test/production/react-18-streaming-ssr/index.test.ts index 93a9a873051f..a1a5e01529f0 100644 --- a/test/production/react-18-streaming-ssr/index.test.ts +++ b/test/production/react-18-streaming-ssr/index.test.ts @@ -38,6 +38,14 @@ describe('react 18 streaming SSR in minimal mode', () => { const html = await renderViaHTTP(next.url, '/') expect(html).toContain('static streaming') }) + + it('should have generated a static 404 page', async () => { + expect(await next.readFile('.next/server/pages/404.html')).toBeTruthy() + + const res = await fetchViaHTTP(next.url, '/non-existent') + expect(res.status).toBe(404) + expect(await res.text()).toContain('This page could not be found') + }) }) describe('react 18 streaming SSR with custom next configs', () => { From e1ed4997ac6800f499e58dfb97ffb1b4fdb6d81f Mon Sep 17 00:00:00 2001 From: JJ Kasper Date: Wed, 30 Mar 2022 12:48:01 -0500 Subject: [PATCH 3/3] update test --- .../test/switchable-runtime.test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/react-streaming-and-server-components/test/switchable-runtime.test.js b/test/integration/react-streaming-and-server-components/test/switchable-runtime.test.js index d5cabd5f9a4e..2c8810fccab3 100644 --- a/test/integration/react-streaming-and-server-components/test/switchable-runtime.test.js +++ b/test/integration/react-streaming-and-server-components/test/switchable-runtime.test.js @@ -113,7 +113,7 @@ describe('Without global runtime configuration', () => { /^[┌├└/]/.test(line) ) const expectedOutputLines = splitLines(` - ┌ λ /404 + ┌ ○ /404 ├ ℇ /edge ├ ℇ /edge-rsc ├ ○ /node