Skip to content

Commit 1d5c5f7

Browse files
fix: tell router that rendering finished when rendering to string (#5174)
fixes #5155 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Bug Fixes** * Improved server-side rendering stability by correctly finalizing the initial render before injecting additional HTML, preventing rare hangs or incomplete pages. * Applies to both React and Solid router SSR paths. * **Performance** * Slightly reduces SSR latency by signaling render completion earlier in the pipeline. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent f5872df commit 1d5c5f7

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

packages/react-router/src/ssr/renderRouterToString.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const renderRouterToString = async ({
1313
}) => {
1414
try {
1515
let html = ReactDOMServer.renderToString(children)
16+
router.serverSsr!.setRenderFinished()
1617
const injectedHtml = await Promise.all(router.serverSsr!.injectedHtml).then(
1718
(htmls) => htmls.join(''),
1819
)

packages/solid-router/src/ssr/renderRouterToString.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const renderRouterToString = async ({
1313
}) => {
1414
try {
1515
let html = Solid.renderToString(children)
16+
router.serverSsr!.setRenderFinished()
1617
const injectedHtml = await Promise.all(router.serverSsr!.injectedHtml).then(
1718
(htmls) => htmls.join(''),
1819
)

0 commit comments

Comments
 (0)