useDeferredValue with an object created during render hangs the page after any re-render (0.3.0)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 57/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- react, typescript, vite
- 領域
- frontend
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- TypeScript
- スター
- 581
- フォーク
- 28
- 平均マージ
- 13時間 48分
- マージ済み PR(30日)
- 45
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
TanStack/redact のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
TanStack/redact#142 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 1〜2日 初心者へのやさしさ 35/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 20/100
メンテナーはふだん 1 日以内に返信
TanStack/redact の issue をすべて見る
似ている issue
-
inference/go type/feature
難易度 1/5 1〜3時間 初心者へのやさしさ 72/100
anomalyco/opencode#65148 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
truapi-release
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
paritytech/product-sdk#529 ·
メンテナーはふだん 1 日以内に返信
-
Add: Mansudae TVオープンapproved check:passed streams:add
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
メンテナーはふだん 1 日以内に返信
-
[Perf] Canvas layer composition is quadratic: splitRenderLayers re-copies the node array per nodeオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
devlikeapro/waha#2369 ·
メンテナーはふだん 5 日以内に返信