- From: jplaisted <notifications@github.com>
- Date: Sat, 14 May 2016 11:43:53 -0700
- To: whatwg/streams <streams@noreply.github.com>
- Cc:
- Message-ID: <whatwg/streams/issues/448@github.com>
With ReadableStreams it appears that if you cancel a stream (or its Reader) the reason for the cancel is only given to the underlying source and not to any consumers. For consumers any pending promises from getReader()/read()/close() will be resolved with undefined/undefined/undefined, true. There is no indication to them that the stream could have ended early or why it did so. I think this would be convenient to have for consumers; that way they can handle *ALL* instances of a stream ending early, expected or not, in the same method. Meaning I feel that cancel should reject all pending promises with the cancel reason rather than resolve them with no information. This would also be slightly confusing for handling getReader() as the reader could be undefined if the stream was canceled. I also get that there are streams where there is no such thing as ending "early" (some kind of dynamic infinite stream that is being cleaned up); but, again, if its an expected reason then the consumer should be able to ignore it. In the current system a consumer will cancel a stream, store a bit that they did cancel it, and then check said bit any time a promise resolves so they ignore the result. Instead what I'm proposing is they just cancel it with a reason, then when a promise rejects if the reason is expected then ignore it. No need to store a variable to remember that you canceled the stream to ignore "phony" results. --- 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/448
Received on Saturday, 14 May 2016 18:44:20 UTC