Re: [whatwg/streams] Support teeing readable byte streams (#1114)

@domenic commented on this pull request.



> +      assert(reader._readRequests.length === 0);
+      ReadableStreamReaderGenericRelease(reader);
+
+      reader = AcquireReadableStreamBYOBReader(stream);
+      forwardReaderError(reader);
+    }
+
+    const readIntoRequest = {
+      chunkSteps: chunk => {
+        // This needs to be delayed a microtask because it takes at least a microtask to detect errors (using
+        // reader._closedPromise below), and we want errors in stream to error both branches immediately. We cannot let
+        // successful synchronously-available reads get ahead of asynchronously-available errors.
+        queueMicrotask(() => {
+          reading = false;
+
+          if (forBranch2 === true) {

I'm not sure; I was genuinely asking :). I guess I was hoping the duplication would be nicer because once you read a single one of them, you'd be able to glaze over when reading the second. But who knows...

-- 
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/1114#discussion_r601880830

Received on Thursday, 25 March 2021 22:32:06 UTC