Re: [streams] Define "tee"ing a stream (#271)

How should clone() or tee() work when the resulting streams are read at wildly different rates?

Consider:

1) UA has an underlying push data source that it can provide back pressure on.  The full data stream is quite large.  To prove the point, lets say something ridiculous like 100 GB.
2) This data source is exposed as a ReadableStream or ReadableByteStream.  We'll call this `stream1`.
3) Content script calls `stream1.clone()` or `stream1.tee()` to create `stream2`.
4) The script then reads `stream1` rapidly, but does not read `stream2` at all.

At this point, the UA must start buffering the underlying data source for all data in-between `stream1`'s read position and `stream2`'s read position.

My question is, can the UA provide back pressure on the underlying data source because `stream2` is not being read?

This might be surprising since it will in effect stall `stream1` until `stream2` starts getting consumed.  The alternative, though, is to buffer until OOM, but that does not seem desirable.

Can the spec clarify that the UA has the freedom to provide back pressure if one of the tee'd streams is read too slowly?

---
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/issues/271#issuecomment-74871856

Received on Wednesday, 18 February 2015 14:28:49 UTC