Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[dynamicIO] Update prerender to use Fizz prerender #71580

Merged
merged 1 commit into from
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 30 additions & 29 deletions packages/next/src/server/app-render/app-render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2028,8 +2028,8 @@ async function spawnDynamicValidationInDev(
const { ServerInsertedHTMLProvider } = createServerInsertedHTML()
const nonce = '1'

const renderToReadableStream = require('react-dom/server.edge')
.renderToReadableStream as (typeof import('react-dom/server.edge'))['renderToReadableStream']
const prerender = require('react-dom/static.edge')
.prerender as (typeof import('react-dom/static.edge'))['prerender']

let clientDynamicTracking = createDynamicTrackingState(false)
let dynamicValidation = createDynamicValidationState()
Expand Down Expand Up @@ -2081,29 +2081,30 @@ async function spawnDynamicValidationInDev(
let hadException = false
try {
await prerenderAndAbortInSequentialTasks(
() => {
const pendingHTMLStream = workUnitAsyncStorage.run(
firstAttemptClientPrerenderStore,
renderToReadableStream,
<App
reactServerStream={firstAttemptReactServerStream}
preinitScripts={() => {}}
clientReferenceManifest={clientReferenceManifest}
ServerInsertedHTMLProvider={ServerInsertedHTMLProvider}
nonce={nonce}
/>,
{
signal: firstAttemptClientController.signal,
onError: SSROnError,
}
)
pendingHTMLStream.catch(() => {})
return pendingHTMLStream
async () => {
workUnitAsyncStorage
.run(
firstAttemptClientPrerenderStore,
prerender,
<App
reactServerStream={firstAttemptReactServerStream}
preinitScripts={() => {}}
clientReferenceManifest={clientReferenceManifest}
ServerInsertedHTMLProvider={ServerInsertedHTMLProvider}
nonce={nonce}
/>,
{
signal: firstAttemptClientController.signal,
onError: SSROnError,
}
)
.catch(() => {})
return null
},
() => {
firstAttemptClientController.abort()
}
)
).catch(() => {})
} catch (err: unknown) {
if (firstAttemptClientController.signal.aborted) {
// We aborted the render normally and can ignore this error
Expand Down Expand Up @@ -2153,7 +2154,7 @@ async function spawnDynamicValidationInDev(
workUnitAsyncStorage
.run(
secondAttemptClientPrerenderStore,
renderToReadableStream,
prerender,
<App
reactServerStream={secondAttemptReactServerStream}
preinitScripts={() => {}}
Expand All @@ -2167,6 +2168,7 @@ async function spawnDynamicValidationInDev(
}
)
.catch(() => {})
return null
},
() => {
secondAttemptClientController.abort()
Expand Down Expand Up @@ -3009,7 +3011,7 @@ async function prerenderToStream(
let htmlStream
try {
htmlStream = await prerenderAndAbortInSequentialTasks(
() => {
async () => {
const teedStream = (
workUnitAsyncStorage.run(
// The store to scope
Expand All @@ -3029,11 +3031,11 @@ async function prerenderToStream(
reactServerStream = teedStream[0]
const rscForSSRStream = teedStream[1]

const renderToReadableStream = require('react-dom/server.edge')
.renderToReadableStream as (typeof import('react-dom/server.edge'))['renderToReadableStream']
const pendingHTMLStream = workUnitAsyncStorage.run(
const prerender = require('react-dom/static.edge')
.prerender as (typeof import('react-dom/static.edge'))['prerender']
const { prelude } = await workUnitAsyncStorage.run(
ssrPrerenderStore,
renderToReadableStream,
prerender,
<App
reactServerStream={rscForSSRStream}
preinitScripts={preinitScripts}
Expand All @@ -3051,8 +3053,7 @@ async function prerenderToStream(
: [bootstrapScript],
}
)
pendingHTMLStream.catch(() => {})
return pendingHTMLStream
return prelude
},
() => {
SSRController.abort(abortReason)
Expand Down
Loading