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

@MattiasBuelens commented on this pull request.



> @@ -3153,10 +3202,14 @@ The following abstract operations support the implementation of the
      |controller|.[=ReadableByteStreamController/[[pendingPullIntos]]=][0].
   1. If ! [$IsDetachedBuffer$](|firstPendingPullInto|'s [=pull-into descriptor/buffer=])
      is true, throw a {{TypeError}} exception.
+  1. Perform ! [$ReadableByteStreamControllerInvalidateBYOBRequest$](|controller|).

Merging the two ifs turned out to be a little tricky. `EnqueueDetachedPullIntoToQueue` eventually calls `ShiftPendingPullInto`, which requires `controller.[[byobRequest]]` to be null. So we must ensure that `InvalidateBYOBRequest` happens *before* `EnqueueDetachedPullIntoToQueue`, but *after* we've done the early-return checks (e.g. throwing a `TypeError` for a detached buffer).

Luckily, it's safe to move the `InvalidateBYOBRequest` call *inside* the if too. If a BYOB request exists, then there must be at least one pull-into descriptor too. 😉

-- 
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/streams/pull/1168#pullrequestreview-847052489

You are receiving this because you are subscribed to this thread.

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

Received on Friday, 7 January 2022 22:46:40 UTC