dillon1000/react
Commit
Browse files [Fizz] write chunks to a buffer with no re-use (#24034)
* write chunks to a buffer with no re-use chunks were previously enqueued to a ReadableStream as they were written. We now write them to a view over an ArrayBuffer and enqueue them only when writing has completed or the buffer's size is exceeded. In addition this copy now ensures we don't attempt to re-send buffers that have already been transferred. * refactor writeChunk to be more defensive and efficient We now defend against overflows using the next views length instead of the current one. this protects us against a future where we use byobRequest and we get longer initial views than we might create after overflowing the first time. Additionally we add in an optimization when we have completely filled up the currentView where we avoid creating subarrays of the chunk to write since it lands exactly on a view boundary. Finally we move the view creation to beginWriting to avoid a runtime check on each write and because we want to reset the view on each beginWriting call in case a throw elsewhere in the program leaves the currentView in an unfinished state * add tests to exercise codepaths dealing with buffer overlows
Changed paths2 files
First-parent comparisonpackages/react-dom/src/__tests__/ReactDOMFizzServerBrowser-test.js ModifiedM packages/react-server/src/ReactServerStreamConfigBrowser.js ModifiedPatch
Files changed
Rendering syntax-highlighted changes…