Unverified Commit f3f3d8a5 authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Node.js streams: Add forkpoint for createCombinedPayloadStream (#92511)

## What?

Building on top of the changes in #92252. This PR implements similar
fork points for createCombinedPayloadStream
parent ce3b173e
......@@ -6048,13 +6048,20 @@ async function validateInstantConfigs(
const clientReferenceManifest = getClientReferenceManifest()
const renderFlightStream = process.env.__NEXT_USE_NODE_STREAMS
? renderToNodeFlightStream
: renderToWebFlightStream
const createDebugChannel = process.env.__NEXT_USE_NODE_STREAMS
? createNodeDebugChannel
: createWebDebugChannel
const {
cache,
payload: initialRscPayload,
stageEndTimes,
} = await collectStagedSegmentData(
ctx.componentMod,
renderToWebFlightStream,
renderFlightStream,
{
[RenderStage.Static]: accumulatedChunks.staticChunks,
[RenderStage.Runtime]: accumulatedChunks.runtimeChunks,
......@@ -6063,7 +6070,8 @@ async function validateInstantConfigs(
debugChunks,
startTime,
hasRuntimePrefetch,
clientReferenceManifest
clientReferenceManifest,
createDebugChannel
)
const { implicitTags, nonce, workStore } = ctx
......@@ -6131,13 +6139,14 @@ async function validateInstantConfigs(
const { stream: serverStream, debugStream } =
await createCombinedPayloadStream(
ctx.componentMod,
renderToWebFlightStream,
renderFlightStream,
payloadResult.payload,
extraChunksController,
reactController.signal,
clientReferenceManifest,
startTime,
isDebugChannelEnabled
isDebugChannelEnabled,
createDebugChannel
)
const instantValidationState = createInstantValidationState(
......
......@@ -41,7 +41,7 @@ import {
createNodeStreamWithLateRelease,
createNodeStreamFromChunks,
} from './stream-utils'
import { createWebDebugChannel } from '../debug-channel-server'
import type { DebugChannelPair } from '../debug-channel-server'
import type { FlightComponentMod } from '../stream-ops'
// eslint-disable-next-line import/no-extraneous-dependencies
......@@ -217,7 +217,8 @@ export async function collectStagedSegmentData(
fullPageDebugChunks: Uint8Array[] | null,
startTime: number,
hasRuntimePrefetch: boolean,
clientReferenceManifest: ClientReferenceManifest
clientReferenceManifest: ClientReferenceManifest,
createDebugChannel: () => DebugChannelPair | undefined
) {
const debugChannelAbortController = new AbortController()
const debugStream = fullPageDebugChunks
......@@ -297,7 +298,7 @@ export async function collectStagedSegmentData(
cacheEntry: SegmentCacheItem
): Promise<void> => {
const segmentDebugChannel = cacheEntry.debugChunks
? createWebDebugChannel()
? createDebugChannel()
: undefined
const itemStream = renderFlightStream(
......@@ -527,7 +528,8 @@ export async function createCombinedPayloadStream(
renderSignal: AbortSignal,
clientReferenceManifest: ClientReferenceManifest,
startTime: number,
isDebugChannelEnabled: boolean
isDebugChannelEnabled: boolean,
createDebugChannel: () => DebugChannelPair | undefined
) {
// Collect all the chunks so that we're not dependent on timing of the render.
......@@ -536,7 +538,7 @@ export async function createCombinedPayloadStream(
const allChunks: Uint8Array[] = []
const debugChunks: Uint8Array[] | null = isDebugChannelEnabled ? [] : null
const debugChannel = isDebugChannelEnabled ? createWebDebugChannel() : null
const debugChannel = isDebugChannelEnabled ? createDebugChannel() : null
let streamFinished: Promise<any>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment