Re: [whatwg/streams] Release reader immediately when shutting down a pipe (PR #1208)

@MattiasBuelens commented on this pull request.



> @@ -475,6 +483,20 @@ function WritableStreamDefaultWriterGetDesiredSize(writer) {
   return WritableStreamDefaultControllerGetDesiredSize(stream._controller);
 }
 
+function WritableStreamDefaultWriterIsOrBecomesErrored(writer, errorListener) {

> Is this very specific to the one change from "writable" to "erroring"?

That's the most noticeable case, since it determines whether or not we may drop a chunk (i.e. we accidentally read a chunk that we can no longer write).

I'm not sure whether it matters for the state transitions of the readable end. There might be an edge case where *two* shutdown conditions become true at the same time, and then it matters which condition is handled first. For example:
```javascript
readableController.error(error1); // pipeTo() should immediately call writer.abort(error1)
writableController.error(error2); // should be ignored, since writable is already erroring
// => pipeTo() rejects with error1
```
versus:
```javascript
writableController.error(error2); // pipeTo() should immediately call reader.cancel(error2)
readableController.error(error1); // should be ignored, since readable is already closed
// => pipeTo() rejects with error2
```
If we were to use a synchronous reaction for the `writable -> erroring` transition but an *asynchronous* reaction for the `readable -> errored` transition, then the first snippet would *also* behave like the second one... I think. 😛

I'll try to whip up some more WPTs to double check.

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

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

Message ID: <whatwg/streams/pull/1208/review/862992215@github.com>

Received on Tuesday, 25 January 2022 23:54:13 UTC