- From: Mattias Buelens <notifications@github.com>
- Date: Wed, 29 Aug 2018 09:39:06 -0700
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
Received on Wednesday, 29 August 2018 16:39:29 UTC
@devsnek That could work... assuming we only add `readable[Symbol.asyncIterator]()`, and *not* `readable.getIterator({ preventCancel })`. If we were to also add `readable.getIterator({ preventCancel })` as a shorthand for `readable.getReader().getIterator({ preventCancel })`, then the stream may end up being locked to a reader with no way to unlock it. Consider: ```js const iterator = readable.getIterator({ preventCancel = true }); iterator.return(); // readable.locked === true; ``` Because `return()` does nothing when `preventCancel === true`, the stream stays locked to the iterator's reader. What should happen in this case? We could call `reader.releaseLock()` from `iterator.return()`, except we might not be able to release the lock because there are still pending reads: ```js const iterator = readable.getIterator({ preventCancel = true }); const readPromise = iterator.next(); iterator.return(); // can't unlock, since read is still pending... what now? ``` I don't know if this is a case we want to support. Perhaps we don't need this, and we only have `readable[Symbol.asyncIterator]()` which will always either consume the whole stream or cancel it. -- 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/950#issuecomment-417019807
Received on Wednesday, 29 August 2018 16:39:29 UTC