react icon indicating copy to clipboard operation
react copied to clipboard

Bug: [React 19 | Streaming SSR] Script tags injected via ChunkExtractor not appearing in final HTML when using renderToPipeableStream

Open sandeep3690Butte opened this issue 3 months ago • 1 comments

Description

I am using React 19, Express, and Streaming SSR (renderToPipeableStream) along with @loadable/server ChunkExtractor to extract and inject script/style tags for client-side hydration.

The loadable-stats.json is generated correctly, and ChunkExtractor.getScriptTags() returns the expected

However, when I inject these

This issue happens even though: Scripts are extracted correctly onAllReady() is called res.write(scripts) is executed SSR output is streamed successfully

React version: 19.2.0

Steps To Reproduce

https://github.com/sandeep3690Butte/node-r19-ssr

1.git clone 2.yarn install 3.yarn build 4.yarn start 5.Open the SSR page → scripts do not appear in view-source or DevTools Network panel.

Repository Structure client/ → all client React code
server/ → Express SSR server
webpack.* → server/client configs for dev + prod

The current behavior

The onAllReady() callback is triggered correctly res.write() executes with no error But no script tags appear in the final HTML Client JS never loads, causing hydration to never run No errors in server logs or browser console

The expected behavior

The

sandeep3690Butte avatar Nov 26 '25 09:11 sandeep3690Butte

We're currently closing the pipe destination by default when you call pipe(stream). That's why calling stream.write() in onAllReady does nothing since the Stream is already closed.

pipe from renderToPipeableStream would need to accept options to prevent closing the destination e.g. https://nodejs.org/api/stream.html#readablepipedestination-options or https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream/pipeTo#options

eps1lon avatar Nov 26 '25 10:11 eps1lon