SSR: an error thrown inside <Suspense> rejects renderToReadableStream instead of falling back to client rendering

Offen
#71 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
55/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
react, typescript
Bereich
backend, testing

Rechercherichtung

Start with the SSR implementation of renderToReadableStream and trace how errors from synchronous throws and rejected lazy imports are handled within Suspense boundaries. Compare the emitted output and onError behavior with the React examples in the issue. Done means both cases report the error, mark the failing boundary for client rendering, and allow the rest of the stream to resolve.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Version: @tanstack/redact 0.2.0 (compared with react-dom 19.2.0)

When a component throws during SSR inside a <Suspense> boundary, Redact's renderToReadableStream rejects the whole stream. React instead reports the error to onError, marks that boundary for client rendering (<!--$!-->), and still resolves the stream.

With TanStack Start, the whole page then returns 500, where React would have degraded only that boundary. We hit this when a third-party module threw at evaluation time inside a code-split route: React had been hiding the error, and Redact turned it into a 500.

Repro: https://github.com/ryoppippi/tanstack-redact-ssr-suspense-error-repro (pnpm install && node repro.mjs)

<html><body>
  <Suspense fallback={<p>loading</p>}>
    <Throws />  {/* throws during render */}
  </Suspense>
</body></html>
react  | sync throw  | ok      | onError=["render error inside Suspense"] | <!DOCTYPE html><html><head></head><body><!--$!--><template data-msg="Switched to client rendering because the server ren
react  | lazy reject | ok      | onError=["lazy chunk failed to evaluate"] | <!DOCTYPE html><html><head></head><body><!--$!--><template data-msg="Switched to client rendering because the server ren
redact | sync throw  | REJECTS | onError=["render error inside Suspense"] | render error inside Suspense
redact | lazy reject | ok      | onError=["lazy chunk failed to evaluate"] | <!DOCTYPE html><html><head></head><body><!--$?0--><div id="B:0"><p>loading</p></div><!--/$--></body></html>

The repro also has a related case: when a lazy() import rejects, Redact resolves the stream but leaves the boundary pending (<!--$?0--> plus the fallback). React marks it for client rendering instead.

Expected: match React. Call onError, emit the client-render marker for the failing boundary, and keep streaming the rest of the document.

Vorherrschende Sprache
TypeScript
Sterne
537
Forks
22
Ø Merge
1 Std. 57 Min.
Gemergte PRs (30 T.)
20

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

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus TanStack/redact

Alle Issues in TanStack/redact

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.