[Flight Reply] Encode binary streams as a single collapsed Blob
Based on #28893.
For other streams we encode each chunk as a separate form field which is a bit bloated. Especially for binary chunks since they also have an indirection. We need some way to encode the chunks as separate anyway. This way the streaming using busboy actually allows each chunk to stream in over the network one at a time.
For binary streams the actual chunking is not important. The chunks can be split and recombined in whatever size chunk makes sense.
Since we buffer the entire content anyway we can combine the chunks to be consecutive. This PR does that with binary streams and also combine them into a single Blob. That way there's no extra overhead when passing through a binary stream.
Ideally, we'd be able to just use the stream from that one Blob but Node.js doesn't return byob streams from Blob. Additionally, we don't actually stream the content of Blobs due to the layering with busboy atm. We could do that for binary streams in particular by replacing the File layering with a stream and resolving each chunk as it comes in. That could be a follow up.
If we stop buffering in the future, this set up still allows us to split them and send other form fields in between while blocked since the protocol is still the same.
Comparing: ec9400dc41715bb6ff0392d6320c33627fa7e2ba...f6b75aab81d05f007e654e76eafb40de0f5bd1c9
Critical size changes
Includes critical production bundles, as well as any change greater than 2%:
| Name | +/- | Base | Current | +/- gzip | Base gzip | Current gzip |
|---|---|---|---|---|---|---|
| oss-stable/react-dom/cjs/react-dom.production.js | = | 6.66 kB | 6.66 kB | +0.05% | 1.82 kB | 1.82 kB |
| oss-stable/react-dom/cjs/react-dom-client.production.js | = | 492.61 kB | 492.61 kB | = | 87.88 kB | 87.88 kB |
| oss-experimental/react-dom/cjs/react-dom.production.js | = | 6.67 kB | 6.67 kB | +0.11% | 1.83 kB | 1.83 kB |
| oss-experimental/react-dom/cjs/react-dom-client.production.js | = | 498.86 kB | 498.86 kB | = | 88.92 kB | 88.93 kB |
| facebook-www/ReactDOM-prod.classic.js | = | 591.22 kB | 591.22 kB | = | 103.96 kB | 103.96 kB |
| facebook-www/ReactDOM-prod.modern.js | = | 567.44 kB | 567.44 kB | = | 100.36 kB | 100.36 kB |
| test_utils/ReactAllWarnings.js | Deleted | 64.26 kB | 0.00 kB | Deleted | 16.02 kB | 0.00 kB |
Significant size changes
Includes any change greater than 0.2%:
Expand to show
Generated by :no_entry_sign: dangerJS against f6b75aab81d05f007e654e76eafb40de0f5bd1c9