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

@domenic commented on this pull request.



> +   1. Perform ! [$ReadableByteStreamControllerError$](|branch2|.[=ReadableStream/[[controller]]=],
+      |r|).
+   1. If |canceled1| is false or |canceled2| is false, [=resolve=] |cancelPromise| with undefined.
+ 1. Let |pullWithDefaultReader| be the following steps:
+  1. If |reader| [=implements=] {{ReadableStreamBYOBReader}},
+   1. Assert: |reader|.[=ReadableStreamBYOBReader/[[readIntoRequests]]=] is [=list/is empty|empty=].
+   1. Perform ! [$ReadableStreamReaderGenericRelease$](|reader|).
+   1. Set |reader| to ! [$AcquireReadableStreamDefaultReader$](|stream|).
+   1. Perform |forwardReaderError|, given |reader|.
+  1. Let |readRequest| be a [=read request=] with the following [=struct/items=]:
+   : [=read request/chunk steps=], given |chunk|
+   ::
+    1. [=Queue a microtask=] to perform the following steps:
+     1. Set |reading| to false.
+     1. Let |chunk1| and |chunk2| be |chunk|.
+     1. If |canceled1| is false and |canceled2| is false, set |chunk2| to ?

Great catch. I think this changed in https://github.com/whatwg/streams/commit/63b4407f424d6ad042852b3d225b7c0ffa116b2d . [Before](https://streams.spec.whatwg.org/commit-snapshots/c63ae9eb7de6069f0e3cf5ea6b0ef68a2c8a3971/#readable-stream-tee), the failure was in a promise handler for a promise that was explicitly marked as [[PromiseIsHandled]]. So I guess such failures were ignored.

These days they go to HTML's "report an exception" for all unhandled exceptions.

Also related: I think the `? ReadableStreamDefaultControllerEnqueue` steps inside the chunk steps should be `!`. (Maybe all call sites for it should be??)

Anyway, what is the correct behavior? I think another option would be to only error branch 2. WDYT? @ricea, any ideas on what makes the most sense from the perspective of how implementations use tee-with-cloneForBranch2-set?

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

Received on Monday, 7 June 2021 18:26:04 UTC