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] Rename onReadyToStream to onCompleteShell #22443

Merged
merged 1 commit into from
Sep 27, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion fixtures/ssr/server/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function render(url, res) {
<App assets={assets} />,
res,
{
onReadyToStream() {
onCompleteShell() {
// If something errored before we started streaming, we set the error code appropriately.
res.statusCode = didError ? 500 : 200;
res.setHeader('Content-type', 'text/html');
Expand Down
2 changes: 1 addition & 1 deletion fixtures/ssr2/server/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = function render(url, res) {
</DataProvider>,
res,
{
onReadyToStream() {
onCompleteShell() {
// If something errored before we started streaming, we set the error code appropriately.
res.statusCode = didError ? 500 : 200;
res.setHeader('Content-type', 'text/html');
Expand Down
6 changes: 3 additions & 3 deletions packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -768,7 +768,7 @@ describe('ReactDOMFizzServer', () => {
writableA,
{
identifierPrefix: 'A_',
onReadyToStream() {
onCompleteShell() {
writableA.write('<div id="container-A">');
startWriting();
writableA.write('</div>');
Expand All @@ -788,7 +788,7 @@ describe('ReactDOMFizzServer', () => {
writableB,
{
identifierPrefix: 'B_',
onReadyToStream() {
onCompleteShell() {
writableB.write('<div id="container-B">');
startWriting();
writableB.write('</div>');
Expand Down Expand Up @@ -1029,7 +1029,7 @@ describe('ReactDOMFizzServer', () => {
writable,
{
namespaceURI: 'http://www.w3.org/2000/svg',
onReadyToStream() {
onCompleteShell() {
writable.write('<svg>');
startWriting();
writable.write('</svg>');
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/server/ReactDOMFizzServerBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type Options = {|
namespaceURI?: string,
progressiveChunkSize?: number,
signal?: AbortSignal,
onReadyToStream?: () => void,
onCompleteShell?: () => void,
onCompleteAll?: () => void,
onError?: (error: mixed) => void,
|};
Expand Down Expand Up @@ -56,7 +56,7 @@ function renderToReadableStream(
options ? options.progressiveChunkSize : undefined,
options ? options.onError : undefined,
options ? options.onCompleteAll : undefined,
options ? options.onReadyToStream : undefined,
options ? options.onCompleteShell : undefined,
);
startWork(request);
},
Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/server/ReactDOMFizzServerNode.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ type Options = {|
identifierPrefix?: string,
namespaceURI?: string,
progressiveChunkSize?: number,
onReadyToStream?: () => void,
onCompleteShell?: () => void,
onCompleteAll?: () => void,
onError?: (error: mixed) => void,
|};
Expand All @@ -57,7 +57,7 @@ function createRequestImpl(
options ? options.progressiveChunkSize : undefined,
options ? options.onError : undefined,
options ? options.onCompleteAll : undefined,
options ? options.onReadyToStream : undefined,
options ? options.onCompleteShell : undefined,
);
}

Expand Down
4 changes: 2 additions & 2 deletions packages/react-dom/src/server/ReactDOMLegacyServerBrowser.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function renderToStringImpl(
};

let readyToStream = false;
function onReadyToStream() {
function onCompleteShell() {
readyToStream = true;
}
const request = createRequest(
Expand All @@ -68,7 +68,7 @@ function renderToStringImpl(
Infinity,
onError,
undefined,
onReadyToStream,
onCompleteShell,
);
startWork(request);
// If anything suspended and is still pending, we'll abort it before writing.
Expand Down
4 changes: 2 additions & 2 deletions packages/react-noop-renderer/src/ReactNoopServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ const ReactNoopServer = ReactFizzServer({

type Options = {
progressiveChunkSize?: number,
onReadyToStream?: () => void,
onCompleteShell?: () => void,
onCompleteAll?: () => void,
onError?: (error: mixed) => void,
};
Expand All @@ -265,7 +265,7 @@ function render(children: React$Element<any>, options?: Options): Destination {
options ? options.progressiveChunkSize : undefined,
options ? options.onError : undefined,
options ? options.onCompleteAll : undefined,
options ? options.onReadyToStream : undefined,
options ? options.onCompleteShell : undefined,
);
ReactNoopServer.startWork(request);
ReactNoopServer.startFlowing(request);
Expand Down
12 changes: 6 additions & 6 deletions packages/react-server/src/ReactFizzServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,10 +190,10 @@ export opaque type Request = {
// onCompleteAll is called when all pending task is done but it may not have flushed yet.
// This is a good time to start writing if you want only HTML and no intermediate steps.
onCompleteAll: () => void,
// onReadyToStream is called when there is at least a root fallback ready to show.
// onCompleteShell is called when there is at least a root fallback ready to show.
// Typically you don't need this callback because it's best practice to always have a
// root fallback ready so there's no need to wait.
onReadyToStream: () => void,
onCompleteShell: () => void,
};

// This is a default heuristic for how to split up the HTML content into progressive
Expand Down Expand Up @@ -227,7 +227,7 @@ export function createRequest(
progressiveChunkSize: void | number,
onError: void | ((error: mixed) => void),
onCompleteAll: void | (() => void),
onReadyToStream: void | (() => void),
onCompleteShell: void | (() => void),
): Request {
const pingedTasks = [];
const abortSet: Set<Task> = new Set();
Expand All @@ -250,7 +250,7 @@ export function createRequest(
partialBoundaries: [],
onError: onError === undefined ? defaultErrorHandler : onError,
onCompleteAll: onCompleteAll === undefined ? noop : onCompleteAll,
onReadyToStream: onReadyToStream === undefined ? noop : onReadyToStream,
onCompleteShell: onCompleteShell === undefined ? noop : onCompleteShell,
};
// This segment represents the root fallback.
const rootSegment = createPendingSegment(request, 0, null, rootFormatContext);
Expand Down Expand Up @@ -1370,8 +1370,8 @@ function finishedTask(
}
request.pendingRootTasks--;
if (request.pendingRootTasks === 0) {
const onReadyToStream = request.onReadyToStream;
onReadyToStream();
const onCompleteShell = request.onCompleteShell;
onCompleteShell();
}
} else {
boundary.pendingTasks--;
Expand Down