Error boundary with a lazy fallback blanks the Suspense boundary when a child throws during hydration (0.3.0)
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 56/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- react, typescript
- 領域
- frontend, testing-qa
調査の方向性
Start by tracing hydration and Suspense error handling in Redact; the report identifies RenderSuspenseCapture when an error boundary renders a lazy fallback. Reproduce the case with the supplied server and client entries, then compare the DOM and page errors with React. Done means hydration preserves or renders the fallback without an unhandled rejection.
索引モデルが issue の本文から書いたものです。
説明
Summary
If a component throws during hydration and the error boundary's fallback is a lazy component, Redact empties the enclosing Suspense boundary and reports an unhandled RenderSuspenseCapture. The fallback never appears, even after the lazy component resolves. React keeps the server-rendered content and shows the fallback.
With a synchronous fallback, the same tree works correctly in Redact.
Reproduction
shared.jsx
import { Component, Suspense, lazy } from 'react'
const isServer = typeof document === 'undefined'
class Boundary extends Component {
state = { error: null }
static getDerivedStateFromError(error) {
return { error }
}
render() {
return this.state.error ? <LazyFallback /> : this.props.children
}
}
function Fallback() {
return <section>something went wrong</section>
}
const LazyFallback = lazy(async () => ({ default: Fallback }))
function Route() {
if (isServer) return <Fallback />
throw new Error('boom')
}
export function App() {
return (
<main>
<Suspense fallback={<p>loading</p>}>
<Boundary>
<Route />
</Boundary>
</Suspense>
</main>
)
}
server.jsx
import { renderToString } from 'react-dom/server'
import { App } from './shared.jsx'
export const render = () => renderToString(<App />)
client.jsx
import { hydrateRoot } from 'react-dom/client'
import { App } from './shared.jsx'
hydrateRoot(document.getElementById('root'), <App />)
Build the server and client entries with and without the redact() plugin, put render()'s output in #root, load the client bundle and wait a moment.
| Runtime | #root after hydration |
Page errors |
|---|---|---|
| React 19.3.1 | <main><section>something went wrong</section></main> |
None |
| Redact 0.3.0 | <main><!--$0--><!--/$--></main> |
RenderSuspenseCapture (unhandled rejection) |
Why this comes up in real apps
Route above copies what TanStack Router's MatchInner does for a route whose loader failed: the server renders the errorComponent directly, and the client throws match.error so the CatchBoundary catches it. When the errorComponent is code-split, the fallback is lazy.
In a TanStack Start app, the server correctly sends the error page with a 500. Hydration then removes it and leaves an empty <main>, so the visitor sees a blank page where the error and its retry action should be. Stopping the router from code-splitting errorComponent avoids the problem.
Possibly related
#137 also involves RenderSuspenseCapture during hydration, but its trigger is different: a boundary suspending again while retrying hydration. Its proposed fix may or may not cover this case, as I have not tested it. #43 changes how errors thrown by a fallback propagate, whereas here the fallback suspends.
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 日以内に返信