Re: [whatwg/streams] ReadableStreamTee: do not read when already pulling (#997)

MattiasBuelens commented on this pull request.



> @@ -592,6 +595,13 @@ function ReadableStreamTee(stream, cloneForBranch2) {
         ReadableStreamDefaultControllerEnqueue(branch2._readableStreamController, value2);
       }
     });
+
+    // If pullPromise rejects with an AssertionError, but the branch is already closed or errored,
+    // the rejection will be silently ignored by ReadableStreamDefaultControllerError.
+    // We have to manually rethrow any AssertionError to make sure they are not ignored.
+    pullPromise.catch(rethrowAssertionErrorRejection);
+
+    return pullPromise;

Okay, so then it'd become:
```js
function pullAlgorithm() {
  if (pulling === true) {
    return Promise.resolve();
  }
  pulling = true;
  ReadableStreamDefaultReaderRead(reader).then(result => {
    pulling = false;
    // ...
  }).catch(rethrowAssertionErrorRejection);
  return Promise.resolve();
}
```
I guess it's not too bad? 😛 

-- 
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/997#discussion_r259847744

Received on Monday, 25 February 2019 14:28:58 UTC