Components that suspend inside a transition load one after another instead of in parallel
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 35/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- typescript
- Domaine
- frontend
Piste de recherche
Start by reading the transition runner in dom/transitions.ts and tracing how handleSuspended handles a promise during a transition render. Use the provided Suspense reproduction to observe when each load starts. Done means sibling loads start in the same pass while the transition still waits for the promises and commits the same result. The issue links a fix commit, so check its status before starting.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
On our website, each component loads its translations lazily: the first render for a locale starts a dynamic import() and throws the promise. Switching locale is wrapped in startTransition.
With React, the switch takes a single round trip. With redact enabled, the old page stays on screen for several seconds, and the network tab shows the chunks fetched strictly one after another (14 chunks, around 5s in production).
Repro
const cache = new Map<string, Promise<string>>()
const load = (key: string) => {
if (!cache.has(key)) {
console.log('start', key)
cache.set(key, fetchText(key))
}
return cache.get(key)!
}
const Text = ({ name, locale }) => <span>{use(load(`${name}-${locale}`))}</span>
const Page = () => {
const [locale, setLocale] = useState('en')
return (
<>
<button onClick={() => startTransition(() => setLocale('fr'))}>fr</button>
<Text name="a" locale={locale} />
<Text name="b" locale={locale} />
<Text name="c" locale={locale} />
</>
)
}
// click "fr"
// React: start a-fr, start b-fr, start c-fr
// redact: start a-fr ... (a-fr resolves) ... start b-fr ... (b-fr resolves) ... start c-fr
Cause
During a transition render,
handleSuspendedthrows the promise straight up to the transition runner (tindom/transitions.ts), which rewinds and retries once that one promise settles. The siblings after the suspended component never render in that pass, so their own loads only start on the next retry. React keeps rendering the siblings of a suspended component (prewarming), so every load starts in the same pass.
Fix
When a held transition suspends on a new promise, render the same fibers once more without throwing (the suspended component renders nothing and its siblings keep going), then rewind that pass. It only starts the work, what the transition waits for and what gets committed don't change.
Fix: https://github.com/aymericzip/redact/commit/18464d7
Related issue: https://github.com/TanStack/redact/issues/137
- Langage dominant
- TypeScript
- Étoiles
- 581
- Forks
- 28
- Merge moyen
- 13 h 48 min
- PR mergées (30 j)
- 45
Préparer son environnement
Ce projet ne fournit ni conteneur de développement, ni Dockerfile, ni guide de contribution : l'installation est à votre charge. Commencez par son README, et consultez notre guide de la première contribution pour les étapes générales.
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/redact
-
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
TanStack/redact#142 · 4 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 85/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 20/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 4/5 3-5 jours Accessibilité débutants 30/100
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de TanStack/redact
Issues similaires
-
inference/go type/feature
Difficulté 1/5 1-3 heures Accessibilité débutants 72/100
anomalyco/opencode#65148 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
truapi-release
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
paritytech/product-sdk#529 ·
Les mainteneurs répondent en général sous 1 jour
-
Add: Mansudae TVOuverteapproved check:passed streams:add
Difficulté 2/5 1-3 heures Accessibilité débutants 64/100
Les mainteneurs répondent en général sous 1 jour
-
[Perf] Canvas layer composition is quadratic: splitRenderLayers re-copies the node array per nodeOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 77/100
devlikeapro/waha#2369 ·
Les mainteneurs répondent en général sous 5 jours