- From: Mattias Buelens <notifications@github.com>
- Date: Thu, 14 Jan 2021 15:33:58 -0800
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/streams/pull/1083/review/568711731@github.com>
@MattiasBuelens commented on this pull request.
> @@ -1456,6 +1456,6 @@ function ReadableStreamFromIterable(asyncIterable) {
return promiseResolvedWith(returnResult);
}
- stream = CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm);
+ stream = CreateReadableStream(startAlgorithm, pullAlgorithm, cancelAlgorithm, 0);
Oh right, I didn't update the spec text yet to pass a zero high-water mark. But I'll first wait until we decide what that high-water mark should be. 😉
> Transform streams are a bit different, as we want introducing them to be more of a no-op and not cause a bunch of chunks to sit in intermediate transform-stream queues, unless explicitly requested.
Hmm... it doesn't look like that's working as intended? 😕
By default, a `TransformStream` is indeed created with a readable HWM of 0, but it still has a **writable HWM** of 1. So piping a stream into it *will* pull at least one chunk, to fill the writable end's queue.
```javascript
var rs1 = new ReadableStream({
pull(c) {
console.log('pull');
c.enqueue('a');
}
}, { highWaterMark: 0 });
// no "pull" is logged yet
var rs2 = rs1.pipeThrough(new TransformStream());
// logs "pull" once
```
There's also no good way to fix this. You can't set both the readable and writable HWM to 0, since then the pipe will stall:
```javascript
var rs1 = new ReadableStream({
pull(c) {
console.log('pull');
c.enqueue('a');
}
}, { highWaterMark: 0 });
var rs2 = rs.pipeThrough(new TransformStream({}, { highWaterMark: 0 }));
var r = rs.getReader();
await r.read(); // never resolves
```
--
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#discussion_r557767509
Received on Thursday, 14 January 2021 23:34:11 UTC