useDeferredValue with an object created during render hangs the page after any re-render (0.3.0)
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 57/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- react, typescript, vite
- Domaine
- frontend
Piste de recherche
Start by tracing v() in packages/redact/src/dom/transitions.ts, then follow how enqueue, scheduleUpdate, flushRoot, renderUpdates, and flushTransitions handle the fiber. Reproduce with the supplied React component and Vite build, with and without redact(). Done when the page stays responsive after the post-mount re-render and a regression check covers this case.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Summary
Passing an object created during render to useDeferredValue hangs the tab as soon as the component re-renders after mount. React settles after 3 renders. Redact renders forever and keeps throwing from the flushPending guard, so the main thread stays busy and the page stops responding.
React's docs warn that this pattern causes an unnecessary background render. It is wasteful there, but it finishes.
Reproduction
No router, Suspense, compiler or hydration is involved.
import { useDeferredValue, useEffect, useState } from 'react'
import { createRoot } from 'react-dom/client'
window.renders = 0
function App() {
window.renders++
const [, setTick] = useState(0)
useDeferredValue({})
useEffect(() => setTick(1), [])
return <p>done</p>
}
createRoot(document.getElementById('root')).render(<App />)
Build with vite build with and without the redact() plugin, then open the page.
| Runtime | Renders after about 3 s | Page errors | Page |
|---|---|---|---|
| React 19.3.1 | 3 | 0 | Responsive |
| Redact 0.3.0 | 3,873,811 | 44,178 | Unresponsive |
These are unminified production builds, so the errors are the bare Error() from flushPending. The count is what had accumulated when I paused the page in the debugger.
The first render does not loop. It takes any re-render after mount, and in my tests a setState in an effect, a setState in a layout effect and a useSyncExternalStore update all triggered it.
Possible cause
This comes from reading the source. I have not tested a patch.
In v() in packages/redact/src/dom/transitions.ts, a normal render whose value differs from hook.s calls enqueue(fiber), which also calls scheduleUpdate(fiber). flushRoot then runs renderUpdates followed by flushTransitions. The transition pass accepts the value, but the fiber still seems to be queued for a normal pass. That pass creates another new object, which differs from hook.s, so it enqueues again.
Real-world impact
I hit this in a TanStack Start app where a hook returned a new query options object on every render, with a stable query key, and the result went to useDeferredValue. The page froze on load under Redact and works under React.
Memoizing the value avoids the loop.
Environment
@tanstack/redact0.3.0 (also 0.2.5), defaultredact()preset- React 19.3.1 (control)
- Vite 7.3.7,
@vitejs/plugin-react5.2.0 - Chromium 156 (Playwright), Node 26
- 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é 4/5 1-2 jours Accessibilité débutants 35/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
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