refactor(FormData/Serializer): Early fix for supporting async blob source #11050
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.
This new FormData Serializer takes a FormData and converts it into a new Blob with other preexisting Blob parts
The benefits
blob.stream()
is called, hence more RAM friendlynew Response(new FormData()).clone()
? but why would you? have have no idea, still a valid case?Other considerations/possible solutions:
Returning a ReadableStream or async iterator... Converting it to a blob seems to be the most easiest... Then fetch can just treat it as a any other blob and don't do any special if-that-then-do-this logic
I have used this formdata-to-blob technique in my formdata-polyfill for years by converting it into a blob since IE9 was a thing in the past
The old Serializer did read the content from File Entries using
_byteSequence
. That is no longer going to be supported once we have async blob sources that can originate from the filesystem and don't hold the data in memory