diff --git a/src/bake/bun-framework-react/server.tsx b/src/bake/bun-framework-react/server.tsx index 2a354d2b27..a377666e68 100644 --- a/src/bake/bun-framework-react/server.tsx +++ b/src/bake/bun-framework-react/server.tsx @@ -159,6 +159,9 @@ export async function render( // Buffer the entire response and return it all at once const htmlStream = renderToHtml(rscPayload, meta.modules, signal); + const result = await htmlStream.bytes(); + + /* const chunks: Uint8Array[] = []; const reader = htmlStream.getReader(); @@ -194,6 +197,7 @@ export async function render( result.set(chunk, offset); offset += chunk.length; } + */ const opts = als?.getStore()?.responseOptions ?? { headers: {} }; const { headers, ...response_options } = opts; diff --git a/src/bake/bun-framework-react/ssr.tsx b/src/bake/bun-framework-react/ssr.tsx index d9e423f977..3b456d3975 100644 --- a/src/bake/bun-framework-react/ssr.tsx +++ b/src/bake/bun-framework-react/ssr.tsx @@ -162,7 +162,7 @@ class RscInjectionStream extends EventEmitter { const { resolve, promise, reject } = Promise.withResolvers(); this.finished = promise; - this.finalize = resolve; + this.finalize = x => (controller.close(), resolve(x)); this.reject = reject; rscPayload.on("data", this.writeRscData.bind(this));