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

[Fizz] Split createRequest into createRequest, createPrerenderRequest and resumeRequest #27342

Merged
merged 2 commits into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
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
13 changes: 6 additions & 7 deletions packages/react-dom/src/server/ReactDOMFizzServerBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import ReactVersion from 'shared/ReactVersion';

import {
createRequest,
startRender,
resumeRequest,
startWork,
startFlowing,
abort,
} from 'react-server/src/ReactFizzServer';
Expand Down Expand Up @@ -129,7 +130,7 @@ function renderToReadableStream(
signal.addEventListener('abort', listener);
}
}
startRender(request);
startWork(request);
});
}

Expand Down Expand Up @@ -171,16 +172,14 @@ function resume(
allReady.catch(() => {});
reject(error);
}
const request = createRequest(
const request = resumeRequest(
children,
postponedState.resumableState,
postponedState,
createRenderState(
postponedState.resumableState,
options ? options.nonce : undefined,
undefined, // importMap
),
postponedState.rootFormatContext,
postponedState.progressiveChunkSize,
options ? options.onError : undefined,
onAllReady,
onShellReady,
Expand All @@ -200,7 +199,7 @@ function resume(
signal.addEventListener('abort', listener);
}
}
startRender(request);
startWork(request);
});
}

Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/server/ReactDOMFizzServerBun.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import ReactVersion from 'shared/ReactVersion';

import {
createRequest,
startRender,
startWork,
startFlowing,
abort,
} from 'react-server/src/ReactFizzServer';
Expand Down Expand Up @@ -121,7 +121,7 @@ function renderToReadableStream(
signal.addEventListener('abort', listener);
}
}
startRender(request);
startWork(request);
});
}

Expand Down
13 changes: 6 additions & 7 deletions packages/react-dom/src/server/ReactDOMFizzServerEdge.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import ReactVersion from 'shared/ReactVersion';

import {
createRequest,
startRender,
resumeRequest,
startWork,
startFlowing,
abort,
} from 'react-server/src/ReactFizzServer';
Expand Down Expand Up @@ -129,7 +130,7 @@ function renderToReadableStream(
signal.addEventListener('abort', listener);
}
}
startRender(request);
startWork(request);
});
}

Expand Down Expand Up @@ -171,16 +172,14 @@ function resume(
allReady.catch(() => {});
reject(error);
}
const request = createRequest(
const request = resumeRequest(
children,
postponedState.resumableState,
postponedState,
createRenderState(
postponedState.resumableState,
options ? options.nonce : undefined,
undefined, // importMap
),
postponedState.rootFormatContext,
postponedState.progressiveChunkSize,
options ? options.onError : undefined,
onAllReady,
onShellReady,
Expand All @@ -200,7 +199,7 @@ function resume(
signal.addEventListener('abort', listener);
}
}
startRender(request);
startWork(request);
});
}

Expand Down
13 changes: 6 additions & 7 deletions packages/react-dom/src/server/ReactDOMFizzServerNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import ReactVersion from 'shared/ReactVersion';

import {
createRequest,
startRender,
resumeRequest,
startWork,
startFlowing,
abort,
} from 'react-server/src/ReactFizzServer';
Expand Down Expand Up @@ -105,7 +106,7 @@ function renderToPipeableStream(
): PipeableStream {
const request = createRequestImpl(children, options);
let hasStartedFlowing = false;
startRender(request);
startWork(request);
return {
pipe<T: Writable>(destination: T): T {
if (hasStartedFlowing) {
Expand Down Expand Up @@ -140,16 +141,14 @@ function resumeRequestImpl(
postponedState: PostponedState,
options: void | ResumeOptions,
) {
return createRequest(
return resumeRequest(
children,
postponedState.resumableState,
postponedState,
createRenderState(
postponedState.resumableState,
options ? options.nonce : undefined,
undefined, // importMap
),
postponedState.rootFormatContext,
postponedState.progressiveChunkSize,
options ? options.onError : undefined,
options ? options.onAllReady : undefined,
options ? options.onShellReady : undefined,
Expand All @@ -166,7 +165,7 @@ function resumeToPipeableStream(
): PipeableStream {
const request = resumeRequestImpl(children, postponedState, options);
let hasStartedFlowing = false;
startRender(request);
startWork(request);
return {
pipe<T: Writable>(destination: T): T {
if (hasStartedFlowing) {
Expand Down
8 changes: 4 additions & 4 deletions packages/react-dom/src/server/ReactDOMFizzStaticBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import type {ImportMap} from '../shared/ReactDOMTypes';
import ReactVersion from 'shared/ReactVersion';

import {
createRequest,
startPrerender,
createPrerenderRequest,
startWork,
startFlowing,
abort,
getPostponedState,
Expand Down Expand Up @@ -80,7 +80,7 @@ function prerender(
options ? options.bootstrapModules : undefined,
options ? options.unstable_externalRuntimeSrc : undefined,
);
const request = createRequest(
const request = createPrerenderRequest(
children,
resources,
createRenderState(
Expand Down Expand Up @@ -109,7 +109,7 @@ function prerender(
signal.addEventListener('abort', listener);
}
}
startPrerender(request);
startWork(request);
});
}

Expand Down
8 changes: 4 additions & 4 deletions packages/react-dom/src/server/ReactDOMFizzStaticEdge.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import type {ImportMap} from '../shared/ReactDOMTypes';
import ReactVersion from 'shared/ReactVersion';

import {
createRequest,
startPrerender,
createPrerenderRequest,
startWork,
startFlowing,
abort,
getPostponedState,
Expand Down Expand Up @@ -80,7 +80,7 @@ function prerender(
options ? options.bootstrapModules : undefined,
options ? options.unstable_externalRuntimeSrc : undefined,
);
const request = createRequest(
const request = createPrerenderRequest(
children,
resources,
createRenderState(
Expand Down Expand Up @@ -109,7 +109,7 @@ function prerender(
signal.addEventListener('abort', listener);
}
}
startPrerender(request);
startWork(request);
});
}

Expand Down
8 changes: 4 additions & 4 deletions packages/react-dom/src/server/ReactDOMFizzStaticNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import {Writable, Readable} from 'stream';
import ReactVersion from 'shared/ReactVersion';

import {
createRequest,
startPrerender,
createPrerenderRequest,
startWork,
startFlowing,
abort,
getPostponedState,
Expand Down Expand Up @@ -94,7 +94,7 @@ function prerenderToNodeStream(
options ? options.bootstrapModules : undefined,
options ? options.unstable_externalRuntimeSrc : undefined,
);
const request = createRequest(
const request = createPrerenderRequest(
children,
resumableState,
createRenderState(
Expand Down Expand Up @@ -123,7 +123,7 @@ function prerenderToNodeStream(
signal.addEventListener('abort', listener);
}
}
startPrerender(request);
startWork(request);
});
}

Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/server/ReactDOMLegacyServerImpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {ReactNodeList} from 'shared/ReactTypes';

import {
createRequest,
startRender,
startWork,
startFlowing,
abort,
} from 'react-server/src/ReactFizzServer';
Expand Down Expand Up @@ -81,7 +81,7 @@ function renderToStringImpl(
undefined,
undefined,
);
startRender(request);
startWork(request);
// If anything suspended and is still pending, we'll abort it before writing.
// That way we write only client-rendered boundaries from the start.
abort(request, abortReason);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {Request} from 'react-server/src/ReactFizzServer';

import {
createRequest,
startRender,
startWork,
startFlowing,
abort,
} from 'react-server/src/ReactFizzServer';
Expand Down Expand Up @@ -92,7 +92,7 @@ function renderToNodeStreamImpl(
undefined,
);
destination.request = request;
startRender(request);
startWork(request);
return destination;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/react-noop-renderer/src/ReactNoopFlightServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function render(model: ReactClientValue, options?: Options): Destination {
options ? options.context : undefined,
options ? options.identifierPrefix : undefined,
);
ReactNoopFlightServer.startRender(request);
ReactNoopFlightServer.startWork(request);
ReactNoopFlightServer.startFlowing(request, destination);
return destination;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/react-noop-renderer/src/ReactNoopServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ function render(children: React$Element<any>, options?: Options): Destination {
options ? options.onAllReady : undefined,
options ? options.onShellReady : undefined,
);
ReactNoopServer.startRender(request);
ReactNoopServer.startWork(request);
ReactNoopServer.startFlowing(request, destination);
return destination;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/react-server-dom-esm/src/ReactFlightDOMServerNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type {ServerContextJSONValue, Thenable} from 'shared/ReactTypes';

import {
createRequest,
startRender,
startWork,
startFlowing,
abort,
} from 'react-server/src/ReactFlightServer';
Expand Down Expand Up @@ -73,7 +73,7 @@ function renderToPipeableStream(
options ? options.onPostpone : undefined,
);
let hasStartedFlowing = false;
startRender(request);
startWork(request);
return {
pipe<T: Writable>(destination: T): T {
if (hasStartedFlowing) {
Expand Down
4 changes: 2 additions & 2 deletions packages/react-server-dom-fb/src/ReactDOMServerFB.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type {BootstrapScriptDescriptor} from 'react-dom-bindings/src/server/Reac

import {
createRequest,
startRender,
startWork,
performWork,
startFlowing,
abort,
Expand Down Expand Up @@ -68,7 +68,7 @@ function renderToStream(children: ReactNodeList, options: Options): Stream {
undefined,
undefined,
);
startRender(request);
startWork(request);
if (destination.fatal) {
throw destination.error;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {ServerManifest} from 'react-client/src/ReactFlightClientConfig';

import {
createRequest,
startRender,
startWork,
startFlowing,
abort,
} from 'react-server/src/ReactFlightServer';
Expand Down Expand Up @@ -70,7 +70,7 @@ function renderToReadableStream(
{
type: 'bytes',
start: (controller): ?Promise<void> => {
startRender(request);
startWork(request);
},
pull: (controller): ?Promise<void> => {
startFlowing(request, controller);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {ServerManifest} from 'react-client/src/ReactFlightClientConfig';

import {
createRequest,
startRender,
startWork,
startFlowing,
abort,
} from 'react-server/src/ReactFlightServer';
Expand Down Expand Up @@ -70,7 +70,7 @@ function renderToReadableStream(
{
type: 'bytes',
start: (controller): ?Promise<void> => {
startRender(request);
startWork(request);
},
pull: (controller): ?Promise<void> => {
startFlowing(request, controller);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type {ServerContextJSONValue, Thenable} from 'shared/ReactTypes';

import {
createRequest,
startRender,
startWork,
startFlowing,
abort,
} from 'react-server/src/ReactFlightServer';
Expand Down Expand Up @@ -74,7 +74,7 @@ function renderToPipeableStream(
options ? options.onPostpone : undefined,
);
let hasStartedFlowing = false;
startRender(request);
startWork(request);
return {
pipe<T: Writable>(destination: T): T {
if (hasStartedFlowing) {
Expand Down
Loading