@@ -233,19 +233,8 @@ app.use('*', async (req, res) => {
233
233
// entry-server.js
234
234
import React from ' react' ;
235
235
import { renderToPipeableStream } from ' react-dom/server' ;
236
- import MultiStream from ' multistream' ;
237
- import { Readable } from ' node:stream' ;
238
236
import App from ' ./App' ;
239
237
240
- // small utility for "readable" streams
241
- const readableString = string => {
242
- const s = new Readable ();
243
- s .push (string);
244
- s .push (null );
245
- s ._read = () => true ;
246
- return s;
247
- };
248
-
249
238
const ABORT_DELAY = 10000 ;
250
239
251
240
async function renderApp ({ res, styledStream }) {
@@ -265,19 +254,15 @@ async function renderApp({ res, styledStream }) {
265
254
266
255
// allow client to start loading js bundle
267
256
res .write (` <!DOCTYPE html><html><head><script defer src="client.js"></script></head><body><div id="root">` );
268
-
269
- const endStream = readableString (' </div></body></html>' );
270
-
271
- // concatenate all streams together
272
- const streams = [
273
- styledStream, // the main content
274
- endStream, // closing tags
275
- ];
276
-
277
- new MultiStream (streams).pipe (res);
278
257
258
+ styledStream .pipe (res, { end: false });
259
+
279
260
// start by piping react and styled transform stream
280
261
pipe (styledStream);
262
+
263
+ styledStream .on (' end' , () => {
264
+ res .end (' </div></body></html>' );
265
+ });
281
266
},
282
267
onError (error ) {
283
268
didError = true ;
0 commit comments