Re: [whatwg/streams] Reject pending reads when releasing reader (#1168)

@domenic commented on this pull request.

Generally looks good, with just a few questions!

> @@ -257,13 +258,18 @@ function ReadableStreamPipeTo(source, dest, preventClose, preventAbort, preventC
     setPromiseIsHandledToTrue(pipeLoop());
 
     function waitForWritesToFinish() {
-      // Another write may have started while we were waiting on this currentWrite, so we have to be sure to wait

Why this change? The previous version seems a bit more understandable, although both are fairly convoluted...

> @@ -745,10 +751,11 @@ function ReadableStreamCancel(stream, reason) {
 
   const reader = stream._reader;
   if (reader !== undefined && ReadableStreamBYOBReader.isImpl(reader)) {
-    for (const readIntoRequest of reader._readIntoRequests) {
+    const readIntoRequests = reader._readIntoRequests;

Interesting. Does this change prevent a concrete bug? Are there tests for the bug?

> @@ -945,6 +965,16 @@ function ReadableStreamDefaultReaderRead(reader, readRequest) {
   }
 }
 
+function ReadableStreamDefaultReaderRelease(reader) {
+  const e = new TypeError('Reader was released');
+  const readRequests = reader._readRequests;
+  reader._readRequests = [];

This dance (lines 970-975) happens enough times it might be worth its own AO.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/1168#pullrequestreview-843984456
You are receiving this because you are subscribed to this thread.

Message ID: <whatwg/streams/pull/1168/review/843984456@github.com>

Received on Tuesday, 4 January 2022 20:43:34 UTC