next.js
839fe54b - Avoid using unclosing prefetch streams in the browser (#89610)

Commit
80 days ago
Avoid using unclosing prefetch streams in the browser (#89610) Previously, `createPrefetchResponseStream` intentionally never called `controller.close()` on the wrapper stream, to prevent React Flight from erroring on unresolved references (dynamic holes). However, Chrome and Firefox keep unclosed ReadableStreams with pending reads as native GC roots, preventing the stream — and the entire FlightResponse captured in the `reader.read().then(progress)` closure chain — from being garbage-collected. Now that React Flight supports `unstable_allowPartialStream` as an option for `createFromReadableStream` (facebook/react#35731), we can close the stream normally. Flight will mark unresolved chunks as "halted" instead of erroring, which is the correct behavior for prefetch responses. Also removes the now-unnecessary `createUnclosingPrefetchStream` wrapper from the legacy prefetch path in `fetch-server-response.ts`. closes #89485
Author
Parents
Loading