Error boundary with a lazy fallback blanks the Suspense boundary when a child throws during hydration (0.3.0)
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 56/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- react, typescript
- Bereich
- frontend, testing-qa
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
- Vorherrschende Sprache
- TypeScript
- Sterne
- 581
- Forks
- 28
- Ø Merge
- 13 Std. 48 Min.
- Gemergte PRs (30 T.)
- 45
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus TanStack/redact
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 84/100
TanStack/redact#142 · 4 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 1-2 Tage Anfängerfreundlichkeit 35/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 20/100
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in TanStack/redact
Ähnliche Issues
-
inference/go type/feature
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 72/100
anomalyco/opencode#65148 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
truapi-release
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 72/100
paritytech/product-sdk#529 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Add: Mansudae TVOffenapproved check:passed streams:add
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 64/100
Maintainer antworten meist innerhalb von 1 Tag
-
[Perf] Canvas layer composition is quadratic: splitRenderLayers re-copies the node array per nodeOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 77/100
devlikeapro/waha#2369 ·
Maintainer antworten meist innerhalb von 5 Tagen