[whatwg/streams] Fix invalid high water mark for tee branches (PR #1234)

strategyHWM must be a positive number because ReadableStreamDefaultControllerShouldCallPull and ReadableByteStreamControllerShouldCallPull return true when desiredSize > 0, so if strategyHWM is zero (and thus desiredSize = strategyHWM - queueTotalSize will initially be 0) the tee branches would signal backpressure forever.

As written, `tee()` would signal backpressure forever. If this were the case we could take the opportunity to fix the backpressure behavior to fully backpressure to the slower consumer rather than only partial backpressuring to the faster consumer (#1233). But alas it looks like various vendors have fixed this bug already at least somewhat.

* [nodejs](https://github.com/nodejs/node/blob/v18.2.0/lib/internal/webstreams/readablestream.js#L1186) uses strategyHWM=1
* [chromium](https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/streams/readable_stream.cc;l=1030;drc=8d6a246c9be4f6b731dc7f6e680b7d5e13a512b5) uses stragegyHWM=1
* from [readableStreamTee](https://github.com/denoland/deno/blob/6a7151539737e4abe1b12095c9e1bc3ed9376f48/ext/web/06_streams.js#L2368), deno apparently creates an always-backpressuring [ReadableByteStreamController](https://github.com/denoland/deno/blob/6a7151539737e4abe1b12095c9e1bc3ed9376f48/ext/web/06_streams.js#L488) (**bug**) but uses strategyHWM=1 for [ReadableByteStreamDefaultController](https://github.com/denoland/deno/blob/6a7151539737e4abe1b12095c9e1bc3ed9376f48/ext/web/06_streams.js#L336)
* Similarly from [ReadableStreamTee](https://searchfox.org/mozilla-central/rev/3419858c997f422e3e70020a46baae7f0ec6dacc/dom/streams/ReadableStream.cpp#819), gecko seems to [CreateReadableStream](https://searchfox.org/mozilla-central/rev/3419858c997f422e3e70020a46baae7f0ec6dacc/dom/streams/ReadableStream.cpp#741) with aHighWaterMark=Nothing which turns into 1.0 for non-byte stream, but for byte streams they [create a ReadableStream with aHighWaterMark=0](https://searchfox.org/mozilla-central/rev/3419858c997f422e3e70020a46baae7f0ec6dacc/dom/streams/ReadableStream.cpp#871) (**bug**)
You can view, comment on, or merge this pull request online at:

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

-- Commit Summary --

  * Fix invalid high water mark for tee branches

-- File Changes --

    M index.bs (4)

-- Patch Links --

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

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

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

Received on Wednesday, 1 June 2022 01:03:07 UTC