router.load() resolves before an ancestor boundary's code-split errorComponent is loaded (regression in 1.170.19)
Les mainteneurs répondent en général sous 1 jour
@Sheraff y travaille déjà.
Depuis le 23/10/2026.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 55/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- Active
- Stack technique
- react, typescript, vite
- Domaine
- frontend
Piste de recherche
Start by tracing router.load() and route chunk loading, especially how an errored child selects an ancestor’s errorComponent; the report points to a regression introduced in 1.170.19 and possibly related to #7926. Use the linked reproducer and its failing test, then compare behavior with 1.170.18. Done means the boundary component is loaded when router.load() resolves and the regression test passes.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Which project does this relate to?
Router
Describe the bug
Since 1.170.19, router.load() can resolve before the chunk for the errorComponent that will actually render has loaded. As a result, the first render after load() suspends and is empty.
This happens when a child's loader throws, the child has no errorComponent, and an ancestor's errorComponent is code-split (which autoCodeSplitting does by default). The errored match only loads its own errorComponent, and the ancestor is success so it only loads component. So nothing preloads the boundary that catches the error. Before 1.170.19, every matched route's chunk loaded all of its component types, so this worked.
const parent = createRoute({
getParentRoute: () => rootRoute,
path: '/parent',
errorComponent: lazyRouteComponent(() => import('./ParentError'), 'ParentError'),
component: () => <Outlet />,
})
const child = createRoute({
getParentRoute: () => parent,
path: '/child',
loader: () => {
throw new Error('child loader failed')
},
component: () => <p>Child</p>,
})
await router.load()
flushSync(() => createRoot(el).render(<RouterProvider router={router} />))
// 1.170.18: el.textContent === 'Parent errorComponent'
// 1.170.46: el.textContent === '', the error component shows up once the chunk arrives
In the browser this is an empty frame. Under Testing Library (IS_REACT_ACT_ENVIRONMENT), the suspended render inside sync act() is never retried, so a test that awaits router.load() and then renders sees a blank page forever. That's how I found it.
Complete minimal reproducer
https://github.com/loganrosen/tanstack-router-load-lazy-error-component
Steps to Reproduce the Bug
pnpm install && pnpm dev, then open the page. The log at the top shows what the first commit afterrouter.load()contained.- On 1.170.46 it logs
first commit: ""and then+312.0ms: "Parent errorComponent". - Set
@tanstack/react-routerto1.170.18,pnpm install, reload. It logsfirst commit: "Parent errorComponent". pnpm testfails on 1.170.46 and passes on 1.170.18.
Expected behavior
When router.load() resolves, the errorComponent/notFoundComponent of the boundary that will render the error should already be loaded, like it was before 1.170.19. The API docs say load() "resolves when they are all loaded and ready to be rendered".
Screenshots or Videos
No response
Platform
- Router / Start Version: @tanstack/react-router 1.170.46 (router-core 1.171.39); works on 1.170.18 (router-core 1.171.15)
- OS: macOS
- Browser: WebKit (macOS system webview)
- Bundler: vite
- Bundler Version: 8.3.5
Additional context
Found while upgrading the router in matrix-authentication-service (element-hq/matrix-authentication-service#6069). We're working around it in our test helper by calling router.loadRouteChunk(route, 'errorComponent') for every match after load(). Possibly related to the loader rewrite in #7926.
The issue was written with help from an AI coding assistant. I ran and checked the reproducer myself.
- Langage dominant
- TypeScript
- Étoiles
- 15.3k
- Forks
- 1.9k
- Merge moyen
- 1 j 5 h
- PR mergées (30 j)
- 46
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de TanStack/router
-
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
Les mainteneurs répondent en général sous 1 jour
-
Masked navigation drops the first character of the hash each time (__tempLocation hash missing '#')Peut-être pris @hassanabrar202 l’a pris il y a 8 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
router-generator: lazy-load Prettier (costs ~300–450ms per build even when formatting is off)Peut-être pris @Sheraff l’a pris il y a 27 jours. Ouvertepackage: router-generator performance
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
Les mainteneurs répondent en général sous 1 jour
-
router-generator: sibling `physical()` subtrees in a virtual route config generate duplicate identifiersPeut-être pris @Sheraff l’a pris il y a 27 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
Les mainteneurs répondent en général sous 1 jour
-
docs(router): clarify static title fallback in SPA modePeut-être pris @Rohan-Dedhia l’a pris il y a 17 jours. Ouverte
Difficulté 1/5 1-3 heures Accessibilité débutants 62/100
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de TanStack/router
Issues similaires
-
[BUG]: Shared links drop the configured basePath on GitHub PagesPeut-être pris @anshulchikhale30-p l’a pris aujourd’hui. Ouvertebug
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
StabilityNexus/IdentityTokens-EVM-Frontend#182 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Add: GTrekkerOuvertecheck:passed streams:add
Difficulté 1/5 Moins d'une heure Accessibilité débutants 72/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 70/100
Koenkk/zigbee-herdsman-converters#13900 ·
Les mainteneurs répondent en général sous 1 jour
-
area: ui Bug Payload OSS
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
payloadcms/payload#19839 ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
jeanibarz/knowledge-base-mcp-server#1291 ·
Les mainteneurs répondent en général sous 1 jour