Route CSS removed on first client-side navigation and never restored (client manifest is pruned to SSR'd matches)
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
- #8225 de @breken-ai — cerrado sin fusionar
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 72/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- react, typescript
Línea de trabajo
Comienza rastreando la deshidratación del manifiesto en router-core/dist/esm/ssr/ssr-server.js, la asignación del cliente en load-client.js y la búsqueda/eliminación de CSS en react-router/dist/esm/headContentUtils.js. Reproduce una compilación de producción cargando la ruta SSR y navegando en el cliente a la ruta del componente compartido; se considera hecho cuando los enlaces CSS compartidos siguen disponibles o se restauran después de la navegación sin deshabilitar la división de CSS.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
On the first client-side navigation away from the server-rendered route, HeadContent removes that route's manifest CSS <link> elements. If the incoming route reuses the same chunk — a component rendered by both routes — nothing re-declares those stylesheets and nothing re-injects them, so the page keeps its class names and loses every rule.
The result looks like a stylesheet that failed to load, but DevTools shows every .css at 200. They loaded, and then their <link> elements were deleted.
Versions
@tanstack/react-start 1.168.49 (latest)
@tanstack/react-router 1.170.32 (latest)
@tanstack/router-core 1.171.27 (latest)
vite 7.3.6 · react 18.3.1 · SSR via Nitro
Reproduction
- A component
<Dashboard />with a CSS-module import, rendered by two routes:/(index)/pool(a layout route, parent of/pool/$id)
- Build for production and load
/directly, so it is server-rendered. - Client-side navigate to
/pool/$id.
Dashboard's stylesheet is removed from <head> and never restored.
It does not reproduce if you arrive at / by client-side navigation from some other route — then the CSS came from Vite's runtime injection, which the router doesn't own and therefore doesn't remove. That asymmetry is what makes it look intermittent in the wild.
What's happening
getStartManifest()returns assets for all routes.serverSsr.dehydrate()prunes to only the matched routes before sending to the client —router-core/dist/esm/ssr/ssr-server.js:301, viagetPreparedMatchedManifestRoutes→prepareMatchedManifestRoutes(:145-161, which iteratesmatchesonly).- The client assigns that pruned object as the whole manifest —
load-client.js:1075:router.ssr = { manifest: dehydratedRouter.manifest }; HeadContentlooks upmanifest.routes[match.routeId]?.css(react-router/dist/esm/headContentUtils.js:65). For any route not in the original SSR match set this isundefined, so no CSS tags are produced.- React unmounts the outgoing route's
<link>elements — correctly, they're its own keyed children. - Vite does not re-inject, because the chunk is already in its module cache.
Observed client-side after loading /:
routes in client manifest: 2 -> __root__, /
"/" css: TooltipButton, GalleryIcon, FocusReveal, BookmarkDashboard
"/pool" css: (NONE)
The server-side manifest has all 34 routes, and /pool there correctly lists all four stylesheets. Only the client's copy is missing them.
MutationObserver on <head> across the navigation, bracketed by the title swap:
12947ms add LINK stylesheet pool-PDzBNjqJ.css <- Vite, for the newly loaded chunk
13464ms REMOVE TITLE
13464ms REMOVE LINK modulepreload ...16 entries...
13464ms REMOVE LINK stylesheet TooltipButton-Dla7QkuC.css
13464ms REMOVE LINK stylesheet GalleryIcon-BwNEuhX0.css
13464ms REMOVE LINK stylesheet FocusReveal-CakzEOUS.css
13464ms REMOVE LINK stylesheet BookmarkDashboard-5xTt8aTr.css
13464ms add TITLE
All three matches are success at that moment (__root__, /pool, /pool/$idSlug), so _getAssetMatches truncation is not involved.
Elements keep their hashed class names (_searchContainer_15j3j_55); the rules are simply gone — padding: 20px 20px 15px → 0px, display: flex → block.
Expected
Either:
- the dehydrated manifest carries assets for all routes (or is extended as routes load), so
HeadContentcan re-declare a stylesheet a newly matched route needs; or HeadContentdoes not remove a stylesheet<link>it cannot guarantee re-adding.
The current combination — prune the client manifest to the SSR'd matches, then remove head assets by route on navigation — means any chunk shared between an SSR'd route and a later-visited route loses its CSS.
Workaround
build.cssCodeSplit: false. One stylesheet, which the manifest attaches to __root__ — always matched, never unmounted, so there is nothing to tear down. Costs ~23 KB gzipped on first load for us.
Note
Filed from a production incident. Happy to put together a minimal standalone reproduction if that would help — the shape above is the whole of it, and the internal trace is included so it can be verified by inspection in the meantime.
- 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