- From: Yonathan Randolph <notifications@github.com>
- Date: Mon, 30 May 2022 20:03:16 -0700
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/streams/pull/1233@github.com>
<!-- Thank you for contributing to the Streams Standard! Please describe the change you are making and complete the checklist below if your change is not editorial. --> Unfortunately, the built-in tee algorithm backpressures to the faster consumer and buffers without limit to the slower consumer. Therefore, it is generally not safe to use when the two branches are read by independent consumers at different speed, since the consumer will eventually run out of memory. I believe that this was an unfortunate design mistake because it conflicts with the suggestion in [Stream requirements:. You must be able to pipe a stream to more than one writable stream.](https://github.com/whatwg/streams/blob/e9355ce79925947e8eb496563d599c329769d315/Requirements.md#you-must-be-able-to-pipe-a-stream-to-more-than-one-writable-stream) which said, “The tee stream can use a number of strategies to govern how the speed of its outputs affect the backpressure signals it gives off, but the simplest strategy is to pass aggregate backpressure signals directly up the chain, thus letting the speed of the slowest output determine the speed of the tee.” This also differs from analogous operations in other libraries such as [repeated nodejs Readable.pipe](https://nodejs.org/api/stream.html#readablepipedestination-options) or [akka-streams Source.alsoTo](https://doc.akka.io/docs/akka/current/stream/operators/Source-or-Flow/alsoTo.html) which backpressure to the *slower* consumer and only require a bounded buffer. As I said in a node-fetch issue https://github.com/node-fetch/node-fetch/issues/1568, I think this unbounded buffering algorithm of `ReadableStream.tee()` from https://github.com/whatwg/streams/pull/311 was a mistake. The built-in operations of a `ReadableStream` should only need a fixed-size buffer. , but at this point it is too late to fix it. But at least we can clarify the informational text, which implied that it is safe to `tee()` a stream and consume it independently. It is generally not safe to consume a `tee()`’d stream independently unless the difference in consumed data fits in memory. - [ ] At least two implementers are interested (and none opposed): - [ ] [Tests](https://github.com/web-platform-tests/wpt) are written and can be reviewed and commented upon at: - [ ] [Implementation bugs](https://github.com/whatwg/meta/blob/main/MAINTAINERS.md#handling-pull-requests) are filed: (See [WHATWG Working Mode: Changes](https://whatwg.org/working-mode#changes) for more details.) You can view, comment on, or merge this pull request online at: https://github.com/whatwg/streams/pull/1233 -- Commit Summary -- * Clarify that tee backpressures to the faster consumed branch -- File Changes -- M index.bs (16) -- Patch Links -- https://github.com/whatwg/streams/pull/1233.patch https://github.com/whatwg/streams/pull/1233.diff -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/streams/pull/1233 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/streams/pull/1233@github.com>
Received on Tuesday, 31 May 2022 03:03:28 UTC