@@ -2241,6 +2241,7 @@ create them does not matter.
2241
2241
1. Assert: |cloneForBranch2| is a boolean.
2242
2242
1. Let |reader| be ? [$AcquireReadableStreamDefaultReader$] (|stream|).
2243
2243
1. Let |reading| be false.
2244
+ 1. Let |readAgain| be false.
2244
2245
1. Let |canceled1| be false.
2245
2246
1. Let |canceled2| be false.
2246
2247
1. Let |reason1| be undefined.
@@ -2249,13 +2250,15 @@ create them does not matter.
2249
2250
1. Let |branch2| be undefined.
2250
2251
1. Let |cancelPromise| be [=a new promise=] .
2251
2252
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.
2253
2256
1. Set |reading| to true.
2254
2257
1. Let |readRequest| be a [=read request=] with the following [=struct/items=] :
2255
2258
: [=read request/chunk steps=] , given |chunk|
2256
2259
::
2257
2260
1. [=Queue a microtask=] to perform the following steps:
2258
- 1. Set |reading | to false.
2261
+ 1. Set |readAgain | to false.
2259
2262
1. Let |chunk1| and |chunk2| be |chunk|.
2260
2263
1. If |canceled2| is false and |cloneForBranch2| is true,
2261
2264
1. Let |cloneResult| be [$StructuredClone$] (|chunk2|).
@@ -2271,6 +2274,8 @@ create them does not matter.
2271
2274
1. If |canceled2| is false, perform !
2272
2275
[$ReadableStreamDefaultControllerEnqueue$] (|branch2|.[=ReadableStream/[[controller]]=] ,
2273
2276
|chunk2|).
2277
+ 1. Set |reading| to false.
2278
+ 1. If |readAgain| is true, perform |pullAlgorithm|.
2274
2279
2275
2280
<p class="note"> The microtask delay here is necessary because it takes at least a microtask to
2276
2281
detect errors, when we use |reader|.[=ReadableStreamGenericReader/[[closedPromise]]=] below.
@@ -2331,6 +2336,8 @@ create them does not matter.
2331
2336
{{ReadableByteStreamController}} .
2332
2337
1. Let |reader| be ? [$AcquireReadableStreamDefaultReader$] (|stream|).
2333
2338
1. Let |reading| be false.
2339
+ 1. Let |readAgainForBranch1| be false.
2340
+ 1. Let |readAgainForBranch2| be false.
2334
2341
1. Let |canceled1| be false.
2335
2342
1. Let |canceled2| be false.
2336
2343
1. Let |reason1| be undefined.
@@ -2357,7 +2364,8 @@ create them does not matter.
2357
2364
: [=read request/chunk steps=] , given |chunk|
2358
2365
::
2359
2366
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.
2361
2369
1. Let |chunk1| and |chunk2| be |chunk|.
2362
2370
1. If |canceled1| is false and |canceled2| is false,
2363
2371
1. Let |cloneResult| be [$CloneAsUint8Array$] (|chunk|).
@@ -2373,6 +2381,9 @@ create them does not matter.
2373
2381
1. If |canceled2| is false, perform !
2374
2382
[$ReadableByteStreamControllerEnqueue$] (|branch2|.[=ReadableStream/[[controller]]=] ,
2375
2383
|chunk2|).
2384
+ 1. Set |reading| to false.
2385
+ 1. If |readAgainForBranch1| is true, perform |pull1Algorithm|.
2386
+ 1. Otherwise, if |readAgainForBranch2| is true, perform |pull2Algorithm|.
2376
2387
2377
2388
<p class="note"> The microtask delay here is necessary because it takes at least a microtask to
2378
2389
detect errors, when we use |reader|.[=ReadableStreamGenericReader/[[closedPromise]]=] below.
@@ -2410,7 +2421,8 @@ create them does not matter.
2410
2421
: [=read-into request/chunk steps=] , given |chunk|
2411
2422
::
2412
2423
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.
2414
2426
1. Let |byobCanceled| be |canceled2| if |forBranch2| is true, and |canceled1| otherwise.
2415
2427
1. Let |otherCanceled| be |canceled2| if |forBranch2| is false, and |canceled1| otherwise.
2416
2428
1. If |otherCanceled| is false,
@@ -2429,6 +2441,9 @@ create them does not matter.
2429
2441
1. Otherwise, if |byobCanceled| is false, perform !
2430
2442
[$ReadableByteStreamControllerRespondWithNewView$] (|byobBranch|.[=ReadableStream/[[controller]]=] ,
2431
2443
|chunk|).
2444
+ 1. Set |reading| to false.
2445
+ 1. If |readAgainForBranch1| is true, perform |pull1Algorithm|.
2446
+ 1. Otherwise, if |readAgainForBranch2| is true, perform |pull2Algorithm|.
2432
2447
2433
2448
<p class="note"> The microtask delay here is necessary because it takes at least a microtask to
2434
2449
detect errors, when we use |reader|.[=ReadableStreamGenericReader/[[closedPromise]]=] below.
@@ -2460,14 +2475,18 @@ create them does not matter.
2460
2475
1. Set |reading| to false.
2461
2476
1. Perform ! [$ReadableStreamBYOBReaderRead$] (|reader|, |view|, |readIntoRequest|).
2462
2477
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.
2464
2481
1. Set |reading| to true.
2465
2482
1. Let |byobRequest| be ! [$ReadableByteStreamControllerGetBYOBRequest$] (|branch1|.[=ReadableStream/[[controller]]=] ).
2466
2483
1. If |byobRequest| is null, perform |pullWithDefaultReader|.
2467
2484
1. Otherwise, perform |pullWithBYOBReader|, given |byobRequest|.[=ReadableStreamBYOBRequest/[[view]]=] and false.
2468
2485
1. Return [=a promise resolved with=] undefined.
2469
2486
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.
2471
2490
1. Set |reading| to true.
2472
2491
1. Let |byobRequest| be ! [$ReadableByteStreamControllerGetBYOBRequest$] (|branch2|.[=ReadableStream/[[controller]]=] ).
2473
2492
1. If |byobRequest| is null, perform |pullWithDefaultReader|.
0 commit comments