Skip to content
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

Add backpressure information to tee, clone #16804

Merged
merged 4 commits into from
Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
pr feedback: grammar
  • Loading branch information
yonran committed May 31, 2022
commit bca6c23ce159350915a757dd5d7880e14f65d6d6
4 changes: 2 additions & 2 deletions files/en-us/web/api/readablestream/tee/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ new {{domxref("ReadableStream")}} instances.

This is useful for allowing two readers to read a stream sequentially or simultaneously,
perhaps at different speeds.
You might do this for example in a ServiceWorker if you want to fetch
For example, you might do this in a ServiceWorker if you want to fetch
a response from the server and stream it to the browser, but also stream it to the
ServiceWorker cache. Since a response body cannot be consumed more than once, you'd need
two copies to do this.
Expand All @@ -28,7 +28,7 @@ A teed stream will backpressure to the speed of the *faster* consumed `ReadableS
and unread data is buffered onto the internal buffer
of the slower consumed `ReadableStream` without any limit or backpressure.
If only one branch is consumed, then the entire body will be buffered in memory.
Therefore, you should not use the build-in `tee()` to read very large streams
Therefore, you should not use the built-in `tee()` to read very large streams
in parallel at different speeds.
Instead, search for an implementation that backpressures
to the speed of the *slower* consumed branch.
Expand Down
2 changes: 1 addition & 1 deletion files/en-us/web/api/response/clone/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ will backpressure to the speed of the *faster* consumed `ReadableStream`,
and unread data is buffered onto the internal buffer
of the slower consumed `ReadableStream` without any limit or backpressure.
If only one branch is consumed, then the entire body will be buffered in memory.
Therefore, you should not use the build-in `clone()` to read very large bodies
Therefore, you should not use the built-in `clone()` to read very large bodies
in parallel at different speeds.

`clone()` throws a {{jsxref("TypeError")}} if the response body has already been used.
Expand Down