next.js
a64db6f7 - refactor: process streaming prerenders more efficiently (#94764)

Commit
26 days ago
refactor: process streaming prerenders more efficiently (#94764) Introducing a brand new concept: processing a stream by having a callback invoked whenever a chunk is emitted. No more tee()ing streams just to run two loops over the chunks from a render. Turns out node streams had it right all along This lets us simplify the (stream) runtime prerender and static prerender codepaths, and will be used further in #94738, where we need to run a staged render with some special accumulation conditions on the chunks. This now becomes easy to add, because we can just pick what we do in our `collectChunk` callback instead of writing an entire loop It will also let us move to switch these codepaths to node streams easier -- the iteration code is the only part that depends on the stream being web or node, the collection logic is generic follow up work: refactor `accumulateStreamChunksInto` and `countStageBytesUntilAbortNode` in the same way. I didn't do that here yet to keep the change focused on what upstack needs
Author
Parents
Loading