- From: Sina Booeshaghi <notifications@github.com>
- Date: Thu, 25 Mar 2021 17:18:06 -0700
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Friday, 26 March 2021 00:21:48 UTC
Sorry, I'm still a bit confused...
If the `read()` method returns `done=true` when there are no more chunks _and_ the stream is closed will the `readAllchunks(readableStream)` function in the streams spec (reproduced below) return `chunks` only if the stream is cancelled (which executes a stream close)? Or the reader is cancelled? Will it ever return chunks?
```js
function readAllChunks(readableStream) {
const reader = readableStream.getReader();
const chunks = [];
return pump();
function pump() {
return reader.read().then(({ value, done }) => {
if (done) {
return chunks;
}
chunks.push(value);
return pump();
});
}
}
```
This is especially confusing since the documentation states that no other consumer can cancel the stream:
> Note how the first thing it does is obtain a reader, and from then on it uses the reader exclusively. This ensures that no other consumer can interfere with the stream, either by reading chunks or by canceling the stream.
--
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/issues/1117#issuecomment-807796680
Received on Friday, 26 March 2021 00:21:48 UTC