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

@MattiasBuelens commented on this pull request.



> @@ -3156,7 +3207,15 @@ The following abstract operations support the implementation of the
   1. Set |firstPendingPullInto|'s [=pull-into descriptor/buffer=] to !
      [$TransferArrayBuffer$](|firstPendingPullInto|'s [=pull-into descriptor/buffer=]).
  1. Perform ! [$ReadableByteStreamControllerInvalidateBYOBRequest$](|controller|).
- 1. If ! [$ReadableStreamHasDefaultReader$](|stream|) is true
+ 1. If |controller|.[=ReadableByteStreamController/[[pendingPullIntos]]=] is not

This hinged on what we wanted to do with the errors from `ReadableByteStreamControllerEnqueueDetachedPullIntoToQueue()`. That is: if that call failed, is it a problem that we did not yet call `ReadableByteStreamControllerInvalidateBYOBRequest()`?

From https://github.com/whatwg/streams/pull/1168#discussion_r779034631, I think the conclusion is: no. If we're going to error the entire stream in response to an allocation failure in `EnqueueDetachedPullIntoToQueue()`, then it doesn't really matter what happens to the BYOB request. So we can do:
1. Transfer `firstPendingPullInto`'s buffer (and throw an error if it's already detached).
2. If `firstPendingPullInto`'s reader type is `"none"`, move its filled bytes to the stream's queue. If this fails, error the stream (and re-throw the error to the caller of `enqueue()`).
3. Invalidate the BYOB request.

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

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

Received on Thursday, 6 January 2022 23:15:51 UTC