[whatwg/streams] ReadableStreamTee: do not read when already pulling (#997)

Currently, when one branch calls `pull()`, it is possible that we call `read()` - even though a `read()` is still pending from a previous `pull()` call by the other branch. This can lead to reading too many chunks from the original streams, and unnecessarily filling up the queues of the branches past their high water mark.

This PR fixes that issue by *only* starting a new `read()` if the previous `read()` was resolved. As a bonus, there will now be only one `read()` that resolves with `{ done: true }` when the original stream closes, so we no longer need to keep track of whether we already closed the two branches.

This implementation passes the new tests by @ricea in web-platform-tests/wpt#15521. I would like to have a few more tests before merging this change, hence the draft state.

Fixes #996.
You can view, comment on, or merge this pull request online at:

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

-- Commit Summary --

  * ReadableStreamTee: do not read when already pulling
  * ReadableStreamTee: remove obsolete closed flag
  * ReadableStreamTee: make sure assertion errors cannot be ignored

-- File Changes --

    M index.bs (7)
    M reference-implementation/lib/readable-stream.js (22)

-- Patch Links --

https://github.com/whatwg/streams/pull/997.patch
https://github.com/whatwg/streams/pull/997.diff

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

Received on Saturday, 23 February 2019 23:33:10 UTC