SSR-enabled beforeLoad on root with ssr: false causes "This Suspense boundary received an update before it finished hydrating."
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 55/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- react, typescript
- Área
- frontend
Línea de trabajo
Comienza con el reproductor proporcionado: ejecuta pnpm install, pnpm dev y visita http://localhost:3000 para observar el error de hidratación. Después inspecciona packages/react-router/src/Match.tsx, especialmente el comportamiento de useStore/useSyncExternalStore durante beforeLoad y la hidratación inicial, junto con la versión anterior enlazada y los issues referenciados. Se considera terminado cuando la root con SSR habilitado y ssr: false se hidrata sin el error de Suspense ni un fallback de renderizado completo en el cliente.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Which project does this relate to?
Router
Describe the bug
When using SSR with tanstack start and router, with a route that has a beforeLoad, a router change-of-state triggers a useSyncExternalStore update / callback. Since useSyncExternalStore is always synchronous, it ignores the startTransition scope of the call stack, fires off a state change immediately, and invalidates the Suspense boundary of the SSR hydration.
The result is this error:
react-dom.development.js:20741 Uncaught Error: This Suspense boundary received an update before it finished hydrating. This caused the boundary to switch to client rendering. The usual way to fix this is to wrap the original update in startTransition.
at updateDehydratedSuspenseComponent (react-dom.development.js:20741:48)
at updateSuspenseComponent (react-dom.development.js:20401:16)
at beginWork (react-dom.development.js:21663:14)
at beginWork$1 (react-dom.development.js:27465:14)
at performUnitOfWork (react-dom.development.js:26596:12)
at workLoopSync (react-dom.development.js:26505:5)
at renderRootSync (react-dom.development.js:26473:7)
at performSyncWorkOnRoot (react-dom.development.js:26124:20)
at flushSyncCallbacks (react-dom.development.js:12042:22)
at flushPassiveEffectsImpl (react-dom.development.js:27099:3)
(Note the fix supplied in the error text is wrong. useSyncExternalStore is never compatible with suspense. See here).
Complete minimal reproducer
https://github.com/fionamatthews-wk/tanstack-router-beforeload-ssr-hydration-error
Steps to Reproduce the Bug
- pnpm install
- pnpm dev
- Visit http://localhost:3000
Note hydration error in console.
Expected behavior
No hydration error. SSR correctly loads and hydrates the server copy without falling back to a full client render.
Screenshots or Videos
No response
Platform
- Router / Start Version: 1.170.32 / 1.168.49
- OS: MacOS
- Browser: Chrome
- Browser Version: 151.0.7922.173
- Bundler: vite
- Bundler Version: 8.2.2
Additional context
It seems likely that #7805 introduced this.
#8055 seems like an attempt to fix this, but our specific case is still receiving a suspense boundary and erroring as of 1.170.32.
I suspect the issue is more to do with calling beforeLoad triggers a store change that a component re-renders for, rather than a question of whether or not the root should be wrapped in suspense.
I placed a breakpoint inside of most useSyncExternalStore subscribers during the initial hydration, and Match.tsx was the first component I found whose useSyncExternalStore (via useStore) is triggering a react update event. Previously, Match.tsx had a filter on its store change. Now, it does not. I suspect that this change, or others like it, are what is causing a synchronous state change callback during suspense that causes react to bail.
I do wonder if ssr: false on a root with SSR enabled is in conflict. However, our current intent is to use SSR for injection of nonces, with investigation into enabling SSR on specific routes postponed until later. Changing ssr to true in the reproduction does get rid of the error, but our intent is not to SSR the root at this time and still have beforeLoad implement our authentication.
- Lenguaje dominante
- TypeScript
- Estrellas
- 15.3k
- Forks
- 1.9k
- Merge medio
- 1 d 5 h
- PR fusionados (30 d)
- 46
Preparar el entorno
Inicia el contenedor de desarrollo del proyecto en tu navegador, con tu propia cuenta de GitHub.
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de TanStack/router
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
Masked navigation drops the first character of the hash each time (__tempLocation hash missing '#')Posiblemente ocupada @hassanabrar202 la tomó hace 8 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
router-generator: lazy-load Prettier (costs ~300–450ms per build even when formatting is off)Posiblemente ocupada @Sheraff la tomó hace 27 días. Abiertopackage: router-generator performance
Dificultad 2/5 1-3 horas Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día
-
router-generator: sibling `physical()` subtrees in a virtual route config generate duplicate identifiersPosiblemente ocupada @Sheraff la tomó hace 27 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
docs(router): clarify static title fallback in SPA modePosiblemente ocupada @Rohan-Dedhia la tomó hace 17 días. Abierto
Dificultad 1/5 1-3 horas Aptitud para principiantes 62/100
Los mantenedores suelen responder en 1 día
Todos los issues de TanStack/router
Issues similares
-
[BUG]: Shared links drop the configured basePath on GitHub PagesPosiblemente ocupada @anshulchikhale30-p la tomó hoy. Abiertobug
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
StabilityNexus/IdentityTokens-EVM-Frontend#182 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Add: GTrekkerAbiertocheck:passed streams:add
Dificultad 1/5 Menos de una hora Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
Koenkk/zigbee-herdsman-converters#13900 ·
Los mantenedores suelen responder en 1 día
-
area: ui Bug Payload OSS
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
payloadcms/payload#19839 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
jeanibarz/knowledge-base-mcp-server#1291 ·
Los mantenedores suelen responder en 1 día