- From: Mattias Buelens <notifications@github.com>
- Date: Wed, 24 Nov 2021 16:24:08 -0800
- To: whatwg/streams <streams@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/streams/pull/1190@github.com>
This adds a new `releaseBackpressure()` method *(name to be decided)* to `WritableStreamDefaultController`, allowing a `WritableStream` with HWM = 0 to resolve the pending `writer.ready` promise manually. This also integrates with `TransformStream`s: when `pull()` is called on the readable side, the transform stream calls `releaseBackpressure()` on its writable side. This allows piping through `TransformStream`s with HWM = 0 on *both* their readable and writable side, enabling "unbuffered" transformations: ```javascript const rs = new ReadableStream({ start(c) { c.enqueue("a"); c.enqueue("b"); c.enqueue("c"); c.close(); } }); const upperCaseTransform = new TransformStream({ transform(chunk, controller) { controller.enqueue(chunk.toUpperCase()); } }, { highWaterMark: 0 }, { highWaterMark: 0 }); const ws = new WritableStream({ write(chunk) { console.log(chunk); } }); await rs.pipeThrough(upperCaseTransform).pipeTo(ws); ``` Previously, the above snippet would stall. Fixes #1158. To do: * [ ] Write spec text * [ ] Write more tests * [ ] Bikeshed on the method name --- - [ ] 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/1190 -- Commit Summary -- * Add WritableStreamDefaultController.releaseBackpressure() * Use releaseBackpressure() in TransformStream pull() algorithm * Roll WPT -- File Changes -- M reference-implementation/lib/WritableStreamDefaultController-impl.js (8) M reference-implementation/lib/WritableStreamDefaultController.webidl (1) M reference-implementation/lib/abstract-ops/transform-streams.js (7) M reference-implementation/lib/abstract-ops/writable-streams.js (20) M reference-implementation/web-platform-tests (2) -- Patch Links -- https://github.com/whatwg/streams/pull/1190.patch https://github.com/whatwg/streams/pull/1190.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/1190
Received on Thursday, 25 November 2021 00:24:20 UTC