Re: [whatwg/streams] ReadableStream.from(asyncIterable) (#1083)

@MattiasBuelens commented on this pull request.

Found some time to write a few tests. More to come. 🙂

Don't worry too much about reviewing this right now, it's the holiday season after all. Enjoy! 😄

> @@ -1456,6 +1456,6 @@ function ReadableStreamFromIterable(asyncIterable) {
     return promiseResolvedWith(returnResult);
   }
 
-  stream = CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm);
+  stream = CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, 0);

Setting the high-water mark to zero ensures `ReadableStream.from(otherReadableStream)` doesn't immediately start pulling from `otherReadableStream`, and matches the default HWM for `TransformStream.readable` (step 5 in [the `TransformStream` constructor](https://streams.spec.whatwg.org/commit-snapshots/660d259fa263e3c0646415a41b6e7b9a13ac4d04/#ts-constructor)).

In comparison, `ReadableStream.tee()` *does* immediately start pulling, even if no `read()` was called on any of the returned branches. In step 16 and 17 of [the `ReadableStreamTee` abstract op](https://streams.spec.whatwg.org/commit-snapshots/660d259fa263e3c0646415a41b6e7b9a13ac4d04/#readable-stream-tee), no value is passed for *highWaterMark* and thus it defaults to 1. This seems to be intentional, as there are tests that rely on this. (In particular, we rely on it to forward closing of the parent stream to the two branches.)

I *think* we want to follow the example of `TransformStream.readable` here, and use zero as HWM? Or am I missing something important?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/1083#pullrequestreview-558895217

Received on Saturday, 26 December 2020 23:17:45 UTC