@@ -2241,6 +2241,7 @@ create them does not matter.
22412241 1. Assert: |cloneForBranch2| is a boolean.
22422242 1. Let |reader| be ? [$AcquireReadableStreamDefaultReader$] (|stream|).
22432243 1. Let |reading| be false.
2244+ 1. Let |readAgain| be false.
22442245 1. Let |canceled1| be false.
22452246 1. Let |canceled2| be false.
22462247 1. Let |reason1| be undefined.
@@ -2249,13 +2250,15 @@ create them does not matter.
22492250 1. Let |branch2| be undefined.
22502251 1. Let |cancelPromise| be [=a new promise=] .
22512252 1. Let |pullAlgorithm| be the following steps:
2252- 1. If |reading| is true, return [=a promise resolved with=] undefined.
2253+ 1. If |reading| is true,
2254+ 1. Set |readAgain| to true.
2255+ 1. Return [=a promise resolved with=] undefined.
22532256 1. Set |reading| to true.
22542257 1. Let |readRequest| be a [=read request=] with the following [=struct/items=] :
22552258 : [=read request/chunk steps=] , given |chunk|
22562259 ::
22572260 1. [=Queue a microtask=] to perform the following steps:
2258- 1. Set |reading | to false.
2261+ 1. Set |readAgain | to false.
22592262 1. Let |chunk1| and |chunk2| be |chunk|.
22602263 1. If |canceled2| is false and |cloneForBranch2| is true,
22612264 1. Let |cloneResult| be [$StructuredClone$] (|chunk2|).
@@ -2271,6 +2274,8 @@ create them does not matter.
22712274 1. If |canceled2| is false, perform !
22722275 [$ReadableStreamDefaultControllerEnqueue$] (|branch2|.[=ReadableStream/[[controller]]=] ,
22732276 |chunk2|).
2277+ 1. Set |reading| to false.
2278+ 1. If |readAgain| is true, perform |pullAlgorithm|.
22742279
22752280 <p class="note"> The microtask delay here is necessary because it takes at least a microtask to
22762281 detect errors, when we use |reader|.[=ReadableStreamGenericReader/[[closedPromise]]=] below.
@@ -2331,6 +2336,8 @@ create them does not matter.
23312336 {{ReadableByteStreamController}} .
23322337 1. Let |reader| be ? [$AcquireReadableStreamDefaultReader$] (|stream|).
23332338 1. Let |reading| be false.
2339+ 1. Let |readAgainForBranch1| be false.
2340+ 1. Let |readAgainForBranch2| be false.
23342341 1. Let |canceled1| be false.
23352342 1. Let |canceled2| be false.
23362343 1. Let |reason1| be undefined.
@@ -2357,7 +2364,8 @@ create them does not matter.
23572364 : [=read request/chunk steps=] , given |chunk|
23582365 ::
23592366 1. [=Queue a microtask=] to perform the following steps:
2360- 1. Set |reading| to false.
2367+ 1. Set |readAgainForBranch1| to false.
2368+ 1. Set |readAgainForBranch2| to false.
23612369 1. Let |chunk1| and |chunk2| be |chunk|.
23622370 1. If |canceled1| is false and |canceled2| is false,
23632371 1. Let |cloneResult| be [$CloneAsUint8Array$] (|chunk|).
@@ -2373,6 +2381,9 @@ create them does not matter.
23732381 1. If |canceled2| is false, perform !
23742382 [$ReadableByteStreamControllerEnqueue$] (|branch2|.[=ReadableStream/[[controller]]=] ,
23752383 |chunk2|).
2384+ 1. Set |reading| to false.
2385+ 1. If |readAgainForBranch1| is true, perform |pull1Algorithm|.
2386+ 1. Otherwise, if |readAgainForBranch2| is true, perform |pull2Algorithm|.
23762387
23772388 <p class="note"> The microtask delay here is necessary because it takes at least a microtask to
23782389 detect errors, when we use |reader|.[=ReadableStreamGenericReader/[[closedPromise]]=] below.
@@ -2410,7 +2421,8 @@ create them does not matter.
24102421 : [=read-into request/chunk steps=] , given |chunk|
24112422 ::
24122423 1. [=Queue a microtask=] to perform the following steps:
2413- 1. Set |reading| to false.
2424+ 1. Set |readAgainForBranch1| to false.
2425+ 1. Set |readAgainForBranch2| to false.
24142426 1. Let |byobCanceled| be |canceled2| if |forBranch2| is true, and |canceled1| otherwise.
24152427 1. Let |otherCanceled| be |canceled2| if |forBranch2| is false, and |canceled1| otherwise.
24162428 1. If |otherCanceled| is false,
@@ -2429,6 +2441,9 @@ create them does not matter.
24292441 1. Otherwise, if |byobCanceled| is false, perform !
24302442 [$ReadableByteStreamControllerRespondWithNewView$] (|byobBranch|.[=ReadableStream/[[controller]]=] ,
24312443 |chunk|).
2444+ 1. Set |reading| to false.
2445+ 1. If |readAgainForBranch1| is true, perform |pull1Algorithm|.
2446+ 1. Otherwise, if |readAgainForBranch2| is true, perform |pull2Algorithm|.
24322447
24332448 <p class="note"> The microtask delay here is necessary because it takes at least a microtask to
24342449 detect errors, when we use |reader|.[=ReadableStreamGenericReader/[[closedPromise]]=] below.
@@ -2460,14 +2475,18 @@ create them does not matter.
24602475 1. Set |reading| to false.
24612476 1. Perform ! [$ReadableStreamBYOBReaderRead$] (|reader|, |view|, |readIntoRequest|).
24622477 1. Let |pull1Algorithm| be the following steps:
2463- 1. If |reading| is true, return [=a promise resolved with=] undefined.
2478+ 1. If |reading| is true,
2479+ 1. Set |readAgainForBranch1| to true.
2480+ 1. Return [=a promise resolved with=] undefined.
24642481 1. Set |reading| to true.
24652482 1. Let |byobRequest| be ! [$ReadableByteStreamControllerGetBYOBRequest$] (|branch1|.[=ReadableStream/[[controller]]=] ).
24662483 1. If |byobRequest| is null, perform |pullWithDefaultReader|.
24672484 1. Otherwise, perform |pullWithBYOBReader|, given |byobRequest|.[=ReadableStreamBYOBRequest/[[view]]=] and false.
24682485 1. Return [=a promise resolved with=] undefined.
24692486 1. Let |pull2Algorithm| be the following steps:
2470- 1. If |reading| is true, return [=a promise resolved with=] undefined.
2487+ 1. If |reading| is true,
2488+ 1. Set |readAgainForBranch2| to true.
2489+ 1. Return [=a promise resolved with=] undefined.
24712490 1. Set |reading| to true.
24722491 1. Let |byobRequest| be ! [$ReadableByteStreamControllerGetBYOBRequest$] (|branch2|.[=ReadableStream/[[controller]]=] ).
24732492 1. If |byobRequest| is null, perform |pullWithDefaultReader|.
0 commit comments