Repository navigation
Open
Description
React version: 19.3.0 (run today). 19.3.1 and 19.3.0-canary-df6aa4ec-20261112 reproduced it on 2026-11-14. Also seen in production as the react-dom 19.3.0-canary-278794d7-20261002 that Next.js 16.4.5 bundles.
Steps To Reproduce
- Put the script below next to
reactandreact-dom19.3.x and runnode repro.cjs. - It renders two
Suspenseboundaries withrenderToPipeableStreaminto a destination that backs up (it holds its first write's callback), lets both boundaries' content render, then lets a child inside the second boundary throw, and only then lets the destination drain.
Link to code example:
// node repro-390.cjs (next to react and react-dom 19.3.x)
const React = require("react");
const { renderToPipeableStream } = require("react-dom/server");
const { Writable } = require("node:stream");
const h = React.createElement;
const later = () => {
let resolve;
const promise = new Promise((r) => (resolve = r));
return { promise, resolve };
};
const first = later();
const second = later();
const third = later();
function Big() {
React.use(first.promise);
return h("div", null, "x".repeat(20000));
}
function Small() {
React.use(second.promise);
return h("p", null, "small");
}
function Thrower() {
React.use(third.promise);
throw new Error("a child that throws after it waited");
}
function Panel() {
React.use(second.promise);
return h("div", null, h(Thrower));
}
const app = h("html", null,
h("body", null,
h(React.Suspense, { fallback: h("p", null, "loading") }, h(Big)),
h(React.Suspense, { fallback: h("p", null, "loading") }, h("section", null, h(Small), h(Panel)))));
// A destination that holds its first write's callback, so the stream backs up until it is released.
let held = null;
const sink = new Writable({
highWaterMark: 1,
write(_chunk, _encoding, done) {
if (held === null) held = done;
else done();
},
});
const tick = (ms = 50) => new Promise((resolve) => setTimeout(resolve, ms));
const { pipe } = renderToPipeableStream(app, {
onShellReady() {
pipe(sink);
},
onError(error) {
console.log("onError:", error.message);
},
});
(async () => {
await tick();
first.resolve();
second.resolve(); // Big and the section's content render while the destination is backed up
await tick();
third.resolve(); // Thrower throws: the second boundary errors while its completed segment is queued
await tick();
const release = held;
held = () => {};
release(); // the destination drains, and React flushes the queued segment
await tick(200);
})();The current behavior
onError is called with the child's error, and then with React's own error 390:
onError: a child that throws after it waited
onError: Aborted, errored or already flushed boundaries should not be flushed again. This is a bug in React.
The stream is cut there. In a framework the page then never receives its bootstrap script: it shows its fallbacks and never hydrates.
The expected behavior
Only the first onError: the second boundary is client-rendered (its fallback and the instruction to render it on the client are written), and the stream completes.
What else we know
- It needs backpressure. With a destination that calls back at once, the same script reports only the child's error and completes. In earlier runs, with the second boundary's content rendered in one task, it did not happen either.
- Where it seems to come from, read from the source and not traced line by line: while the destination is backed up, the second boundary's completed segment waits in its
completedSegments. The child then errors and the boundary becomes client-rendered, but when the destination drains, the partial-boundary flush still writes the queued segment, meets the errored child, andflushSegmentreaches itsdefaultcase. - Not fixed by [Fizz] Fix truncated prerender output under backpressure #37901 (Fix truncated prerender output under backpressure, merged 2026-10-19): the canary of 2026-11-12 still reproduced it on 2026-11-14.
- How we met it: in a Next.js App Router page, two server-rendered cards under one
Suspense, where a client component in one card throws during the server render. About 1 load in 100 on an idle machine, far more under load. Awaiting everything the boundary holds before rendering any of it narrows the window, since the throw then happens in the task that first renders the boundary, but React's flight stream still splits a large payload into later rows, so it does not close it.
Metadata
Metadata
Assignees
Labels
No labels
Activity
omerfarukgurbuz commentedon Nov 19, 2026
I’ll investigate the backpressure case on
mainin GitHub Codespaces and work on a Node regression test that checks the stream finishes and emits the client-render instruction after the child throws.