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

@MattiasBuelens 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've tried [something different](https://github.com/whatwg/streams/blob/78b76ee7dd6720c8bffb82cc142c1bcc05bb10ca/index.bs#L2407-L2410) to reduce duplication. Have a look! 🙂

-- 
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_r644363725

Received on Wednesday, 2 June 2021 22:36:33 UTC