-
Notifications
You must be signed in to change notification settings - Fork 47k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Flight Reply] Encode ReadableStream and AsyncIterables #28893
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
facebook-github-bot
added
CLA Signed
React Core Team
Opened by a member of the React Core Team
labels
Apr 23, 2024
gnoff
approved these changes
May 2, 2024
// Generators/Iterators are Iterables but they're also their own iterator | ||
// functions. If that's the case, we treat them as single-shot. Otherwise, | ||
// we assume that this iterable might be a multi-shot and allow it to be | ||
// iterated more than once on the client. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment copy from the non-reply version?
sebmarkbage
added a commit
that referenced
this pull request
May 8, 2024
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.
github-actions bot
pushed a commit
that referenced
this pull request
May 8, 2024
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. DiffTrain build for [826bf4e](826bf4e)
eps1lon
added a commit
to vercel/next.js
that referenced
this pull request
May 16, 2024
Completes #65845 which only updated Canary not Experimental. <details> <summary> React upstream changes</summary> - facebook/react#29026 - facebook/react#29025 - facebook/react#28743 - facebook/react#29022 - facebook/react#29023 - facebook/react#29015 - facebook/react#29016 - facebook/react#28988 - facebook/react#28987 - facebook/react#28986 - facebook/react#29014 - facebook/react#28982 - facebook/react#29006 - facebook/react#28973 - facebook/react#28841 - facebook/react#28964 - facebook/react#28990 - facebook/react#29003 - facebook/react#28989 - facebook/react#28893 - facebook/react#28887 - facebook/react#28807 - facebook/react#28978 - facebook/react#28963 - facebook/react#28972 - facebook/react#28970 - facebook/react#28816 - facebook/react#28977 - facebook/react#28974 - facebook/react#28976 - facebook/react#28975 - facebook/react#28969 - facebook/react#28966 - facebook/react#28056 </details>
panteliselef
pushed a commit
to panteliselef/next.js
that referenced
this pull request
May 20, 2024
Completes vercel#65845 which only updated Canary not Experimental. <details> <summary> React upstream changes</summary> - facebook/react#29026 - facebook/react#29025 - facebook/react#28743 - facebook/react#29022 - facebook/react#29023 - facebook/react#29015 - facebook/react#29016 - facebook/react#28988 - facebook/react#28987 - facebook/react#28986 - facebook/react#29014 - facebook/react#28982 - facebook/react#29006 - facebook/react#28973 - facebook/react#28841 - facebook/react#28964 - facebook/react#28990 - facebook/react#29003 - facebook/react#28989 - facebook/react#28893 - facebook/react#28887 - facebook/react#28807 - facebook/react#28978 - facebook/react#28963 - facebook/react#28972 - facebook/react#28970 - facebook/react#28816 - facebook/react#28977 - facebook/react#28974 - facebook/react#28976 - facebook/react#28975 - facebook/react#28969 - facebook/react#28966 - facebook/react#28056 </details>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Same as #28847 but in the other direction.
Like other promises, this doesn't actually stream in the outgoing direction. It buffers until the stream is done. This is mainly due to our protocol remains compatible with Safari's lack of outgoing streams until recently.
However, the stream chunks are encoded as separate fields and so does support the busboy streaming on the receiving side.