fix(fetch): use structuredClone in clone body steps#1697
Merged
mcollina merged 1 commit intonodejs:mainfrom Oct 13, 2022
Merged
fix(fetch): use structuredClone in clone body steps#1697mcollina merged 1 commit intonodejs:mainfrom
mcollina merged 1 commit intonodejs:mainfrom
Conversation
Codecov ReportBase: 94.09% // Head: 94.08% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #1697 +/- ##
==========================================
- Coverage 94.09% 94.08% -0.01%
==========================================
Files 53 53
Lines 4912 4923 +11
==========================================
+ Hits 4622 4632 +10
- Misses 290 291 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
ronag
approved these changes
Oct 13, 2022
mrbbot
added a commit
to cloudflare/miniflare
that referenced
this pull request
Dec 23, 2022
`5.11.0` includes nodejs/undici#1643. There are some non-trivial changes required to upgrade to `5.14.0`: - Since `[email protected]` (nodejs/undici#1697), `structuredClone` is used on bodies, which may be byte streams. Due to a Node bug (nodejs/node#45955), readable byte streams cannot be transferred, breaking `fetch`. - Since `[email protected]` (nodejs/undici#1793), global `ReadableStream` and `TransformStream` are used if available. In the Vitest environment, (which modifies the global scope unlike Jest which runs tests in a VM context), if the `streams_enable_constructors` compatibility flag isn't enabled, `fetch` breaks as `ReadableStream`s can't be constructed.
metcoder95
pushed a commit
to metcoder95/undici
that referenced
this pull request
Dec 26, 2022
crysmags
pushed a commit
to crysmags/undici
that referenced
this pull request
Feb 27, 2024
This file contains hidden or 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
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.
Refs: #1666 (comment)
Enables the following WPTs (only Safari currently passes these tests, and the same 2 tests fail here):
https://wpt.fyi/results/fetch/api/response/response-clone.any.html?label=master&label=experimental&aligned&view=subtest
The spec does tell implementations to clone the stream, but you have to go down a few layers:
Let « out1, out2 » be the result of teeing body’s stream.
To tee a ReadableStream stream, return ? ReadableStreamTee(stream, true).
ReadableStreamTee(stream, cloneForBranch2) will tee a given readable stream.
The second argument, cloneForBranch2, governs whether or not the data from the original stream will be cloned (using HTML’s serializable objects framework) before appearing in the second of the returned branches.