File tree Expand file tree Collapse file tree 1 file changed +24
-1
lines changed
packages/packagers/react-static/src Expand file tree Collapse file tree 1 file changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -215,7 +215,30 @@ export default (new Packager({
215215 let { prelude} = await prerender ( React . createElement ( Content ) , {
216216 bootstrapScriptContent,
217217 } ) ;
218- let response = prelude . pipeThrough ( injectRSCPayload ( injectStream ) ) ;
218+
219+ // Buffer into a single chunk so hash reference replacement works correctly.
220+ // There could potentially be a more optimal way of doing this in the future.
221+ let buffers = [ ] ;
222+ let len = 0 ;
223+ let bufferedStream = new TransformStream ( {
224+ transform ( chunk ) {
225+ len += chunk . length ;
226+ buffers . push ( chunk ) ;
227+ } ,
228+ flush ( controller ) {
229+ let concated = new Uint8Array ( len ) ;
230+ let offset = 0 ;
231+ for ( let buf of buffers ) {
232+ concated . set ( buf , offset ) ;
233+ offset += buf . length ;
234+ }
235+ controller . enqueue ( concated ) ;
236+ } ,
237+ } ) ;
238+
239+ let response = prelude . pipeThrough (
240+ injectRSCPayload ( injectStream . pipeThrough ( bufferedStream ) ) ,
241+ ) ;
219242
220243 return [
221244 {
You can’t perform that action at this time.
0 commit comments