Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite ReadableStream.pipeTo() using the public API #99

Merged
merged 20 commits into from
Oct 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
bded0f3
Implement pipeTo() using the public API (WIP)
MattiasBuelens Sep 29, 2021
2158b08
Allow reader/writer.closed to settle before starting pipe loop
MattiasBuelens Sep 29, 2021
e03f2c7
Detect stream state from closed promise
MattiasBuelens Oct 1, 2021
89ce2d9
Combine closed promise reactions
MattiasBuelens Oct 1, 2021
9fd38ba
Don't start pipe loop if already shutting down
MattiasBuelens Oct 1, 2021
88e71a0
Reimplement WritableStreamDefaultWriterCloseWithErrorPropagation
MattiasBuelens Oct 1, 2021
f03d40a
Ignore errors from closed promises after releasing reader/writer
MattiasBuelens Oct 1, 2021
5250596
Wait for initial source/dest state before running shutdown actions
MattiasBuelens Oct 1, 2021
4e9ab0f
Remove early return when signal is already aborted
MattiasBuelens Oct 1, 2021
392eb5e
Skip broken test
MattiasBuelens Oct 23, 2021
d77b1dd
Wait for both reads and writes to finish before finalizing pipe
MattiasBuelens Oct 23, 2021
f20ac4a
Ignore a few more tests for now
MattiasBuelens Oct 23, 2021
c48e1b1
Fix indentation
MattiasBuelens Oct 23, 2021
6739f40
Simplify
MattiasBuelens Oct 24, 2021
8b06dbf
Re-implement close with error propagation
MattiasBuelens Oct 24, 2021
f2b9d19
Add extra delay to allow reader.closed and writer.closed to settle
MattiasBuelens Oct 24, 2021
5eaafbf
Re-enable test
MattiasBuelens Oct 26, 2021
74d782f
Add extra unit test for skipped pipe WPT test
MattiasBuelens Oct 26, 2021
a93fc55
Add extra tests for skipped multiple propagation WPT tests
MattiasBuelens Oct 26, 2021
4903491
Document new WPT failures
MattiasBuelens Oct 27, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ It aims to pass all tests, although it allows some exceptions for practical reas
* The tests [with patched globals][wpt-rs-patched-global] and [with `Object.prototype.then`][wpt-then-interception].
These tests are meant for browsers to ensure user-land modifications cannot affect the internal logic of `pipeTo()` and `tee()`.
However, it's not reasonable or desirable for a user-land polyfill to try and isolate itself completely from using the global `Object`.
* Certain `pipeTo()` tests that require synchronous inspection of the stream's state ([1][wpt-pipe-sync-state-1], [2][wpt-pipe-sync-state-2]).
Because the polyfill uses the public `getReader()` and `getWriter()` API to implement `pipeTo()`, it can only *asynchronously* observe if and when a stream becomes closed or errored.
Therefore, when the readable and the writable end become errored *at the exact same time*, it's difficult for the polyfill to observe these state changes in exactly the same order.
* The ES5 variant passes the same tests as the ES2015 variant, except for various tests about specific characteristics of the constructors, properties and methods.
These test failures do not affect the run-time behavior of the polyfill.
For example:
Expand Down Expand Up @@ -127,4 +130,6 @@ Thanks to these people for their work on [the original polyfill][creatorrr-polyf
[stub-async-iterator-prototype]: https://github.com/MattiasBuelens/web-streams-polyfill/blob/v4.0.0-beta.1/src/lib/readable-stream/async-iterator.ts#L153-L161
[wpt-rs-patched-global]: https://github.com/web-platform-tests/wpt/blob/887350c2f46def5b01c4dd1f8d2eee35dfb9c5bb/streams/readable-streams/patched-global.any.js
[wpt-then-interception]: https://github.com/web-platform-tests/wpt/blob/cf33f00596af295ee0f207c88e23b5f8b0791307/streams/piping/then-interception.any.js
[wpt-pipe-sync-state-1]: https://github.com/web-platform-tests/wpt/blob/e1e713c842e54ea0a9410ddc988b63d0e1d31973/streams/piping/multiple-propagation.any.js#L30-L53
[wpt-pipe-sync-state-2]: https://github.com/web-platform-tests/wpt/blob/e1e713c842e54ea0a9410ddc988b63d0e1d31973/streams/piping/multiple-propagation.any.js#L114-L138
[creatorrr-polyfill]: https://github.com/creatorrr/web-streams-polyfill
2 changes: 1 addition & 1 deletion src/lib/readable-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export type ReadableByteStream = ReadableStream<Uint8Array> & {
_readableStreamController: ReadableByteStreamController
};

type ReadableStreamState = 'readable' | 'closed' | 'errored';
export type ReadableStreamState = 'readable' | 'closed' | 'errored';

/**
* A readable stream represents a source of data, from which you can read.
Expand Down
Loading