Skip to content

Commit 1e8ad31

Browse files
committed
Expose maxBoundarySize as an option
1 parent ab84723 commit 1e8ad31

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

packages/react-dom/src/server/ReactDOMFizzServerBrowser.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import {
1818

1919
type Options = {
2020
signal?: AbortSignal,
21+
maxBoundarySize?: number,
2122
};
2223

2324
function renderToReadableStream(
@@ -30,7 +31,11 @@ function renderToReadableStream(
3031
}
3132
return new ReadableStream({
3233
start(controller) {
33-
request = createRequest(children, controller);
34+
request = createRequest(
35+
children,
36+
controller,
37+
options ? options.maxBoundarySize : undefined,
38+
);
3439
startWork(request);
3540
},
3641
pull(controller) {

packages/react-dom/src/server/ReactDOMFizzServerNode.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ function createDrainHandler(destination, request) {
2121
return () => startFlowing(request);
2222
}
2323

24+
type Options = {
25+
maxBoundarySize?: number,
26+
};
27+
2428
type Controls = {
2529
// Cancel any pending I/O and put anything remaining into
2630
// client rendered mode.
@@ -30,8 +34,13 @@ type Controls = {
3034
function pipeToNodeWritable(
3135
children: ReactNodeList,
3236
destination: Writable,
37+
options?: Options,
3338
): Controls {
34-
const request = createRequest(children, destination);
39+
const request = createRequest(
40+
children,
41+
destination,
42+
options ? options.maxBoundarySize : undefined,
43+
);
3544
destination.on('drain', createDrainHandler(destination, request));
3645
startWork(request);
3746
return {

packages/react-noop-renderer/src/ReactNoopServer.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,11 @@ const ReactNoopServer = ReactFizzServer({
210210
},
211211
});
212212

213-
function render(children: React$Element<any>): Destination {
213+
type Options = {
214+
maxBoundarySize?: number,
215+
};
216+
217+
function render(children: React$Element<any>, options?: Options): Destination {
214218
const destination: Destination = {
215219
root: null,
216220
placeholders: new Map(),
@@ -220,7 +224,11 @@ function render(children: React$Element<any>): Destination {
220224
ReactNoopServer.abort(request);
221225
},
222226
};
223-
const request = ReactNoopServer.createRequest(children, destination);
227+
const request = ReactNoopServer.createRequest(
228+
children,
229+
destination,
230+
options ? options.maxBoundarySize : undefined,
231+
);
224232
ReactNoopServer.startWork(request);
225233
return destination;
226234
}

packages/react-server/src/ReactFizzServer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,13 +116,14 @@ type Request = {
116116
export function createRequest(
117117
children: ReactNodeList,
118118
destination: Destination,
119+
maxBoundarySize: number = 1024,
119120
): Request {
120121
const pingedWork = [];
121122
const abortSet: Set<SuspendedWork> = new Set();
122123
const request = {
123124
destination,
124125
responseState: createResponseState(),
125-
maxBoundarySize: 1024,
126+
maxBoundarySize,
126127
status: BUFFERING,
127128
nextSegmentId: 0,
128129
allPendingWork: 0,

0 commit comments

Comments
 (0)