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

In #1207, we raised concern about whether it's currently possible for `pipeTo()` to drop chunks when the pipe shuts down *while it still has a pending read request*.

It turns out that this *is* indeed possible. The new WPT tests demonstrate at least one way this can happen, by aborting a pipe with an `AbortSignal`.

This PR fixes this by releasing the pipe's reader immediately when *starting* the shutdown process, rather than when it *finalizes* the shutdown. This ensures that any pending reads that were started are immediately rejected, and the chunks stay in the source's queue.

This does have the side effect of releasing the reader *before* the pipe promise resolves. I don't know if this is acceptable.

- [ ] At least two implementers are interested (and none opposed):
   * …
   * …
- [ ] [Tests](https://github.com/web-platform-tests/wpt) are written and can be reviewed and commented upon at:
   * …
- [ ] [Implementation bugs](https://github.com/whatwg/meta/blob/main/MAINTAINERS.md#handling-pull-requests) are filed:
   * Chrome: …
   * Firefox: …
   * Safari: …

(See [WHATWG Working Mode: Changes](https://whatwg.org/working-mode#changes) for more details.)

You can view, comment on, or merge this pull request online at:

  https://github.com/whatwg/streams/pull/1208


-- Commit Summary --

  * Ensure pipeTo() calls the correct Release() depending on the chosen reader
  * Release reader immediately when shutting down a pipe

-- File Changes --

    M index.bs (8)
    M reference-implementation/lib/abstract-ops/readable-streams.js (7)

-- Patch Links --

https://github.com/whatwg/streams/pull/1208.patch

https://github.com/whatwg/streams/pull/1208.diff


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

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

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

Received on Sunday, 16 January 2022 00:07:46 UTC