diff --git a/packages/next/server/node-web-streams-helper.ts b/packages/next/server/node-web-streams-helper.ts index 9512d9cbffa65..692c80f0b9e6e 100644 --- a/packages/next/server/node-web-streams-helper.ts +++ b/packages/next/server/node-web-streams-helper.ts @@ -1,3 +1,5 @@ +import { nonNullable } from '../lib/non-nullable' + export function readableStreamTee( readable: ReadableStream ): [ReadableStream, ReadableStream] { @@ -172,7 +174,7 @@ export async function continueFromInitialStream({ suffixUnclosed != null ? createPrefixStream(suffixUnclosed) : null, dataStream ? createInlineDataStream(dataStream) : null, suffixUnclosed != null ? createSuffixStream(closeTag) : null, - ].filter(Boolean) as any + ].filter(nonNullable) return transforms.reduce( (readable, transform) => readable.pipeThrough(transform), diff --git a/packages/next/server/render.tsx b/packages/next/server/render.tsx index 221adf792a47b..6f9191547645c 100644 --- a/packages/next/server/render.tsx +++ b/packages/next/server/render.tsx @@ -72,7 +72,6 @@ import { streamToString, chainStreams, createBufferedTransformStream, - renderToStream, renderToInitialStream, continueFromInitialStream, } from './node-web-streams-helper' @@ -1628,17 +1627,7 @@ export async function renderToHTML( ) - let documentHTML: string - if (hasConcurrentFeatures) { - const documentStream = await renderToStream({ - ReactDOMServer, - element: document, - generateStaticHTML: true, - }) - documentHTML = await streamToString(documentStream) - } else { - documentHTML = ReactDOMServer.renderToStaticMarkup(document) - } + const documentHTML = ReactDOMServer.renderToStaticMarkup(document) if (process.env.NODE_ENV !== 'production') { const nonRenderedComponents = [] diff --git a/test/integration/react-streaming-and-server-components/app/pages/index.server.js b/test/integration/react-streaming-and-server-components/app/pages/index.server.js index 89723996bfd08..d7eb0906e41d0 100644 --- a/test/integration/react-streaming-and-server-components/app/pages/index.server.js +++ b/test/integration/react-streaming-and-server-components/app/pages/index.server.js @@ -10,6 +10,7 @@ export default function Index({ header }) {
+ hello, {envVar}

{`component:index.server`}

{'env:' + envVar}
diff --git a/test/integration/react-streaming-and-server-components/test/basic.js b/test/integration/react-streaming-and-server-components/test/basic.js index 43c18775269fe..852a870ea0c06 100644 --- a/test/integration/react-streaming-and-server-components/test/basic.js +++ b/test/integration/react-streaming-and-server-components/test/basic.js @@ -10,6 +10,11 @@ export default async function basic(context, { env }) { expect(pathNotFoundHTML).toContain('custom-404-page') }) + it('should render title correctly', async () => { + const res = await renderViaHTTP(context.appPort, '/') + expect(res).toContain('hello, env_var_test') + }) + it('should support api routes', async () => { const res = await renderViaHTTP(context.appPort, '/api/ping') expect(res).toContain('pong')