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

Explicitly set highWaterMark to 0 for ReadableStream #24641

Merged
merged 2 commits into from May 31, 2022
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
20 changes: 12 additions & 8 deletions packages/react-dom/src/server/ReactDOMFizzServerBrowser.js
Expand Up @@ -53,15 +53,19 @@ function renderToReadableStream(
});

function onShellReady() {
const stream: ReactDOMServerReadableStream = (new ReadableStream({
type: 'bytes',
pull(controller) {
startFlowing(request, controller);
const stream: ReactDOMServerReadableStream = (new ReadableStream(
{
type: 'bytes',
pull(controller) {
startFlowing(request, controller);
},
cancel(reason) {
abort(request);
},
},
cancel(reason) {
abort(request);
},
}): any);
// $FlowFixMe size() methods are not allowed on byte streams.
{highWaterMark: 0},
): any);
// TODO: Move to sub-classing ReadableStream.
stream.allReady = allReady;
resolve(stream);
Expand Down
Expand Up @@ -33,16 +33,20 @@ function renderToReadableStream(
options ? options.onError : undefined,
context,
);
const stream = new ReadableStream({
type: 'bytes',
start(controller) {
startWork(request);
const stream = new ReadableStream(
{
type: 'bytes',
start(controller) {
startWork(request);
},
pull(controller) {
startFlowing(request, controller);
},
cancel(reason) {},
},
pull(controller) {
startFlowing(request, controller);
},
cancel(reason) {},
});
// $FlowFixMe size() methods are not allowed on byte streams.
{highWaterMark: 0},
);
return stream;
}

Expand Down