Rename onReadyToStream to onCompleteShell (#22443)
Sebastian Markbåge committed
Sep 27, 2021 at 15:38 UTC
2cc6d79c98bcd1b17b83c47de29895342db5caeb
8 files changed
+19
-19
fixtures/ssr/server/render.js
+1
-1
@@ -24,7 +24,7 @@ export default function render(url, res) {
24
<App assets={assets} />,
25
res,
26
{
27
- onReadyToStream() {
27
+ onCompleteShell() {
28
// If something errored before we started streaming, we set the error code appropriately.
29
res.statusCode = didError ? 500 : 200;
30
res.setHeader('Content-type', 'text/html');
fixtures/ssr2/server/render.js
+1
-1
@@ -43,7 +43,7 @@ module.exports = function render(url, res) {
43
</DataProvider>,
44
res,
45
{
46
- onReadyToStream() {
46
+ onCompleteShell() {
47
// If something errored before we started streaming, we set the error code appropriately.
48
res.statusCode = didError ? 500 : 200;
49
res.setHeader('Content-type', 'text/html');
packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js
+3
-3
@@ -768,7 +768,7 @@ describe('ReactDOMFizzServer', () => {
768
writableA,
769
{
770
identifierPrefix: 'A_',
771
- onReadyToStream() {
771
+ onCompleteShell() {
772
writableA.write('<div id="container-A">');
773
startWriting();
774
writableA.write('</div>');
@@ -788,7 +788,7 @@ describe('ReactDOMFizzServer', () => {
788
writableB,
789
{
790
identifierPrefix: 'B_',
791
- onReadyToStream() {
791
+ onCompleteShell() {
792
writableB.write('<div id="container-B">');
793
startWriting();
794
writableB.write('</div>');
@@ -1029,7 +1029,7 @@ describe('ReactDOMFizzServer', () => {
1029
writable,
1030
{
1031
namespaceURI: 'http://www.w3.org/2000/svg',
1032
- onReadyToStream() {
1032
+ onCompleteShell() {
1033
writable.write('<svg>');
1034
startWriting();
1035
writable.write('</svg>');
packages/react-dom/src/server/ReactDOMFizzServerBrowser.js
+2
-2
@@ -28,7 +28,7 @@ type Options = {|
28
namespaceURI?: string,
29
progressiveChunkSize?: number,
30
signal?: AbortSignal,
31
- onReadyToStream?: () => void,
31
+ onCompleteShell?: () => void,
32
onCompleteAll?: () => void,
33
onError?: (error: mixed) => void,
34
|};
@@ -56,7 +56,7 @@ function renderToReadableStream(
56
options ? options.progressiveChunkSize : undefined,
57
options ? options.onError : undefined,
58
options ? options.onCompleteAll : undefined,
59
- options ? options.onReadyToStream : undefined,
59
+ options ? options.onCompleteShell : undefined,
60
);
61
startWork(request);
62
},
packages/react-dom/src/server/ReactDOMFizzServerNode.js
+2
-2
@@ -32,7 +32,7 @@ type Options = {|
32
identifierPrefix?: string,
33
namespaceURI?: string,
34
progressiveChunkSize?: number,
35
- onReadyToStream?: () => void,
35
+ onCompleteShell?: () => void,
36
onCompleteAll?: () => void,
37
onError?: (error: mixed) => void,
38
|};
@@ -57,7 +57,7 @@ function createRequestImpl(
57
options ? options.progressiveChunkSize : undefined,
58
options ? options.onError : undefined,
59
options ? options.onCompleteAll : undefined,
60
- options ? options.onReadyToStream : undefined,
60
+ options ? options.onCompleteShell : undefined,
61
);
62
}
63
packages/react-dom/src/server/ReactDOMLegacyServerBrowser.js
+2
-2
@@ -54,7 +54,7 @@ function renderToStringImpl(
54
};
55
56
let readyToStream = false;
57
- function onReadyToStream() {
57
+ function onCompleteShell() {
58
readyToStream = true;
59
}
60
const request = createRequest(
@@ -68,7 +68,7 @@ function renderToStringImpl(
68
Infinity,
69
onError,
70
undefined,
71
- onReadyToStream,
71
+ onCompleteShell,
72
);
73
startWork(request);
74
// If anything suspended and is still pending, we'll abort it before writing.
packages/react-noop-renderer/src/ReactNoopServer.js
+2
-2
@@ -242,7 +242,7 @@ const ReactNoopServer = ReactFizzServer({
242
243
type Options = {
244
progressiveChunkSize?: number,
245
- onReadyToStream?: () => void,
245
+ onCompleteShell?: () => void,
246
onCompleteAll?: () => void,
247
onError?: (error: mixed) => void,
248
};
@@ -265,7 +265,7 @@ function render(children: React$Element<any>, options?: Options): Destination {
265
options ? options.progressiveChunkSize : undefined,
266
options ? options.onError : undefined,
267
options ? options.onCompleteAll : undefined,
268
- options ? options.onReadyToStream : undefined,
268
+ options ? options.onCompleteShell : undefined,
269
);
270
ReactNoopServer.startWork(request);
271
ReactNoopServer.startFlowing(request);
packages/react-server/src/ReactFizzServer.js
+6
-6
@@ -190,10 +190,10 @@ export opaque type Request = {
190
// onCompleteAll is called when all pending task is done but it may not have flushed yet.
191
// This is a good time to start writing if you want only HTML and no intermediate steps.
192
onCompleteAll: () => void,
193
- // onReadyToStream is called when there is at least a root fallback ready to show.
193
+ // onCompleteShell is called when there is at least a root fallback ready to show.
194
// Typically you don't need this callback because it's best practice to always have a
195
// root fallback ready so there's no need to wait.
196
- onReadyToStream: () => void,
196
+ onCompleteShell: () => void,
197
};
198
199
// This is a default heuristic for how to split up the HTML content into progressive
@@ -227,7 +227,7 @@ export function createRequest(
227
progressiveChunkSize: void | number,
228
onError: void | ((error: mixed) => void),
229
onCompleteAll: void | (() => void),
230
- onReadyToStream: void | (() => void),
230
+ onCompleteShell: void | (() => void),
231
): Request {
232
const pingedTasks = [];
233
const abortSet: Set<Task> = new Set();
@@ -250,7 +250,7 @@ export function createRequest(
250
partialBoundaries: [],
251
onError: onError === undefined ? defaultErrorHandler : onError,
252
onCompleteAll: onCompleteAll === undefined ? noop : onCompleteAll,
253
- onReadyToStream: onReadyToStream === undefined ? noop : onReadyToStream,
253
+ onCompleteShell: onCompleteShell === undefined ? noop : onCompleteShell,
254
};
255
// This segment represents the root fallback.
256
const rootSegment = createPendingSegment(request, 0, null, rootFormatContext);
@@ -1370,8 +1370,8 @@ function finishedTask(
1370
}
1371
request.pendingRootTasks--;
1372
if (request.pendingRootTasks === 0) {
1373
- const onReadyToStream = request.onReadyToStream;
1374
- onReadyToStream();
1373
+ const onCompleteShell = request.onCompleteShell;
1374
+ onCompleteShell();
1375
}
1376
} else {
1377
boundary.pendingTasks--;