`lazyRouteComponent` shares a pending import across requests on the server: on Cloudflare Workers one cancelled request breaks the route for the isolate
Les mainteneurs répondent en général sous 1 jour
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 72/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- react, typescript
- Domaine
- backend, performance
Piste de recherche
Start with packages/react-router/src/lazyRouteComponent.tsx, especially the server and client paths around loadPromise; the issue includes a reproduction and a proposed server-side fix. Run the reproducer in the linked repository, then verify that cancelling an import request no longer makes later requests for the same route fail, while the existing client behavior remains intact.
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
On Cloudflare Workers a promise only settles in the request that created it (handle_cross_request_promise_resolution, default since 2024-10-14). On the server, lazyRouteComponent keeps loadPromise for later requests (by design, "SSR can reuse the import"):
If the request that started the import is cancelled before it settles, loadPromise never settles and is never cleared. Every later SSR of that route fails ("Something went wrong!", 500) until the isolate is recycled; other routes keep working.
Reproduction: in 20/20 runs, every later /about answers 500 while / stays 200; with the diff below, 0/20.
Suggested fix, server branch only (keep the component, not the promise):
const load = () => {
+ if (isServer ?? typeof window === 'undefined') {
+ if (comp) {
+ return Promise.resolve()
+ }
+ error = undefined
+ return importer()
+ .then((res) => {
+ comp ??= res[exportName ?? 'default']
+ })
+ .catch((err) => {
+ error = err
+ })
+ }
if (!loadPromise) {
Complete minimal reproducer
https://github.com/LlamaLtda/workers-lazy-import-cross-request-repro/tree/main/tanstack-router
Steps to Reproduce the Bug
cd tanstack-router && npm install && npm run repro- The script starts
wrangler devwith the app (router SSR in a plain Worker,/aboutuseslazyRouteComponent) and a second Worker that calls it through a service binding. - It requests
/, then requests/aboutand aborts that call while the component import is pending (the importer waits 200 ms beforeimport()to make the window deterministic). Aborting a service-binding call cancels the callee's request, as Cloudflare does when a visitor leaves. - It requests
/aboutand/five more times and prints the statuses.npm run repro -- --fixedapplies the diff above.
Also reproduced inside a default TanStack Start app, where autoCodeSplitting wraps every route component in lazyRouteComponent on the server (tanstack-start/, --mode route-component): 20/20, and 0/20 with the diff above.
Expected behavior
Cancelling one request affects only that request: later /about requests answer 200. Instead they answer 500 with Error: This promise was created by a request that has since ended, so it can never settle. serialized in the page.
Platform
- Router / Start Version: @tanstack/react-router 1.170.46 (latest), router-core 1.171.39; Start case: @tanstack/react-start 1.169.5
- OS: Linux x64
- Browser: n/a (server-side)
- Bundler: wrangler 4.164.0 (esbuild) for the Router case; vite 8.3.8 + @cloudflare/vite-plugin 1.70.0 for the Start case
- Runtime: workerd via
wrangler dev,compatibility_date2026-11-01
Additional context
router-core'sloadRouteChunkkeepsroute._lazythe same way (load-client.ts L80-L105); not exercised here (.lazy()routes).- Start has the same pattern in
getEntriesand the manifest caches: TanStack/router#8951. Also h3 (h3js/h3#1661), Nitro (nitrojs/nitro#5153), and Astro (withastro/astro#18764, fixed).
AI disclosure: this report was written and filed by an AI agent (Claude Code) acting for the owner of this account, on the project where the bug was hit in production. The agent built and ran the reproduction; the raw outputs are in the repo's results/ folder.
- 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