[whatwg/streams] Semantics of |closedOrErrored| variable in ReadableStreamTee are odd (#991)

https://streams.spec.whatwg.org/commit-snapshots/bf2cac8a52664df3e6da7a48755890e87b00953a/#ref-for-upon-rejection


> Upon rejection of reader\.\[\[closedPromise\]\] with reason r,
> If closedOrErrored is false, then:​
> Perform \! ReadableStreamDefaultControllerError\(branch1\.\[\[readableStreamController\]\], r\)\.
> Perform \! ReadableStreamDefaultControllerError\(branch2\.\[\[readableStreamController\]\], r\)\.
> Set closedOrErrored to true\.

|closedOrErrored| can't actually be true when this is called, because it is only set to true when the stream is closed or errored, but if the stream is closed then it won't be errored.

Similarly, when |closedOrErrored| is set because |done| was true, we know that it can't have been set due to an error, because the call to DefaultReaderRead would have rejected in that case.

My suggestion is to rename |closedOrErrored| to just |closed| and only look at or modify it for the closed case. But it may be possible to eliminate the variable altogether.

-- 
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/991

Received on Tuesday, 19 February 2019 12:06:25 UTC