Re: [whatwg/streams] TransformStream cleanup using "Transformer.cancel" (PR #1283)

@lucacasonato commented on this pull request.



> -   1. If |readable|.[=ReadableStream/[[state]]=] is "`errored`", throw
-      |readable|.[=ReadableStream/[[storedError]]=].

Because _I think_, it is not possible for the readable to get into the errored state while this processing is happening.

Let me explain:

1. User calls `writable.close()`, returning promise 1
2. `WS#close` hook is called, invoking `TransformStreamDefaultSinkCloseAlgorithm`. The close algorithm returns a pending promise
3. User calls `readable.cancel()`, returning promise 2
4. `RS#cancel` hook is called, returning `finishPromise` (which is pending)
5. close algorithm pending promise is resolved
6. `finishPromise` gets resolved because of this (in `TransformStreamDefaultSinkCloseAlgorithm`)
7. promise 1 resolves
8. promise 2 resolves

The error passed to `readable.cancel()` is swallowed.

Because the `controller` of the RS is not exposed to the user, it is not possible to close the RS without going thru `cancelAlgorithm` in the TS.

This is inline with my comments above that all of `rs.cancel`, `ws.close` and `ws.abort` will all either resolve or reject (never one resolves one rejects), and that the first one always wins.





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

Message ID: <whatwg/streams/pull/1283/review/1532329739@github.com>

Received on Monday, 17 July 2023 09:12:56 UTC