We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 795ee1b commit f7bb020Copy full SHA for f7bb020
1 file changed
packages/router-core/src/ssr/transformStreamWithRouter.ts
@@ -271,11 +271,13 @@ export function transformStreamWithRouter(
271
const html = router.serverSsr?.takeBufferedHtml()
272
if (!html) return
273
274
- if (isAppRendering) {
275
- // Buffer for insertion at next valid position
+ if (isAppRendering || leftover) {
+ // Buffer when app is still rendering OR when there's leftover content
276
+ // that hasn't been flushed yet. This prevents race conditions where
277
+ // injected HTML appears before buffered app content
278
pendingRouterHtmlParts.push(html)
279
} else {
- // App is done rendering, write directly to output
280
+ // App done rendering and no leftover - safe to write directly for better streaming
281
safeEnqueue(html)
282
}
283
})
0 commit comments