Skip to content

Commit 0e0318e

Browse files
committed
Don't close the server stream when we finish the main stream
This event is fired if we're the ones closing it. Instead we let it close naturally when we finish after closing the debug channel.
1 parent 5f10b66 commit 0e0318e

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

packages/react-server-dom-esm/src/server/ReactFlightDOMServerNode.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -214,10 +214,13 @@ function renderToPipeableStream(
214214
'The destination stream errored while writing data.',
215215
),
216216
);
217-
destination.on(
218-
'close',
219-
createCancelHandler(request, 'The destination stream closed early.'),
220-
);
217+
// We don't close until the debug channel closes.
218+
if (!__DEV__ || debugChannelReadable === undefined) {
219+
destination.on(
220+
'close',
221+
createCancelHandler(request, 'The destination stream closed early.'),
222+
);
223+
}
221224
return destination;
222225
},
223226
abort(reason: mixed) {

packages/react-server-dom-parcel/src/server/ReactFlightDOMServerNode.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,13 @@ export function renderToPipeableStream(
226226
'The destination stream errored while writing data.',
227227
),
228228
);
229-
destination.on(
230-
'close',
231-
createCancelHandler(request, 'The destination stream closed early.'),
232-
);
229+
// We don't close until the debug channel closes.
230+
if (!__DEV__ || debugChannelReadable === undefined) {
231+
destination.on(
232+
'close',
233+
createCancelHandler(request, 'The destination stream closed early.'),
234+
);
235+
}
233236
return destination;
234237
},
235238
abort(reason: mixed) {

packages/react-server-dom-turbopack/src/server/ReactFlightDOMServerNode.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,13 @@ function renderToPipeableStream(
220220
'The destination stream errored while writing data.',
221221
),
222222
);
223-
destination.on(
224-
'close',
225-
createCancelHandler(request, 'The destination stream closed early.'),
226-
);
223+
// We don't close until the debug channel closes.
224+
if (!__DEV__ || debugChannelReadable === undefined) {
225+
destination.on(
226+
'close',
227+
createCancelHandler(request, 'The destination stream closed early.'),
228+
);
229+
}
227230
return destination;
228231
},
229232
abort(reason: mixed) {

packages/react-server-dom-webpack/src/server/ReactFlightDOMServerNode.js

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,13 @@ function renderToPipeableStream(
220220
'The destination stream errored while writing data.',
221221
),
222222
);
223-
destination.on(
224-
'close',
225-
createCancelHandler(request, 'The destination stream closed early.'),
226-
);
223+
// We don't close until the debug channel closes.
224+
if (!__DEV__ || debugChannelReadable === undefined) {
225+
destination.on(
226+
'close',
227+
createCancelHandler(request, 'The destination stream closed early.'),
228+
);
229+
}
227230
return destination;
228231
},
229232
abort(reason: mixed) {

0 commit comments

Comments
 (0)