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

Add a brand check to pipeThrough() #966

Merged
merged 4 commits into from
Nov 27, 2018

Conversation

ricea
Copy link
Collaborator

@ricea ricea commented Nov 22, 2018

Require pipeThrough() to be called on a ReadableStream. Stop delegating to
this.pipeTo().

Also throw exceptions if this or writable are not streams or they are
locked, or if signal is not an AbortSignal. Also require readable to be a
ReadableStream.

Add a new abstract operation, ReadableStreamPipeTo(), which is used internally
by pipeTo() and pipeThrough() and also can be referenced from other
standards.

Closes #961.


Preview | Diff

Require pipeThrough() to be called on a ReadableStream. Stop delegating
to this.pipeTo().

Also throw exceptions if *this* or _writable_ are not streams or they
are locked, or if *signal* is not an AbortSignal. Also require
_readable_ to be a ReadableStream.

Add a new abstract operation, ReadableStreamPipeTo(), which is used
internally by pipeTo() and pipeThrough() and also can be referenced from
other standards.

Closes whatwg#961.
Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with nits... will check the tests to ensure they test the changed semantics.

@@ -661,31 +661,31 @@ option. If <code><a for="underlying source">type</a></code> is set to <code>unde
</div>

<h5 id="rs-pipe-through" method for="ReadableStream" lt="pipeThrough(transform, options)">pipeThrough({
<var ignore>writable</var>, <var ignore>readable</var> }, <var ignore>options</var>)</h5>
<var ignore>writable</var>, <var ignore>readable</var> }, { <var>preventClose</var>, <var>preventAbort</var>,
<var>preventCancel</var>, <var>signal</var> } = {})</h5>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also update the class definition to use this style?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

_preventCancel_ to ! ToBoolean(_preventCancel_).
1. If _signal_ is not *undefined*, and _signal_ is not an instance of the `<a idl>AbortSignal</a>` interface, throw a
*TypeError* exception.
1. If ! IsReadableStreamLocked(*this*) is *true*, throw a *TypeError* exception.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting that these now throw sync exceptions instead of returning a rejected promise that gets ignored. This is probably the right thing to do...

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The alternative would be to error readable. That would have the benefit that the whole pipe chain would be errored in the normal case, and so you'd get a rejection rather than an exception. But it wouldn't work properly if readable was locked. It also would be a big departure from our behaviour up until now of passing through readable unchanged.

On balance, I think throwing an exception here is the best approach.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed, sync exceptions make the most sense. WebIDL says that you should return a rejected promise if the function's return type is a promise, and otherwise you should throw an exception. Since pipeThrough returns a ReadableStream, sync exceptions would be the correct choice. 🙂

The alternative would be to error readable.

This seems like a bad alternative, for all the reasons you've mentioned. It would be very unexpected that a wrong usage of the stream would cause it to error.

@domenic
Copy link
Member

domenic commented Nov 26, 2018

When merging this we should be sure to file browser bugs; see https://github.com/whatwg/meta/blob/master/MAINTAINERS.md#handling-pull-requests

Reflect the new definition of pipeThrough
@ricea
Copy link
Collaborator Author

ricea commented Nov 27, 2018

When merging this we should be sure to file browser bugs; see https://github.com/whatwg/meta/blob/master/MAINTAINERS.md#handling-pull-requests

I filed https://bugs.chromium.org/p/chromium/issues/detail?id=908747 for Chrome. Edge and Firefox don't have implementations. It would probably not be helpful to file issues saying "implement pipeThrough". Safari appears to have a semi-functional pipeThrough that delegates to a non-functional pipeTo. I've no idea what to do about that.

@domenic
Copy link
Member

domenic commented Nov 27, 2018

LGTM, merge at will after the tests. I forgot about the implementation status, so yeah, probably it's OK to not do the bugs...

ricea added a commit to web-platform-tests/wpt that referenced this pull request Nov 27, 2018
…14193)

Remove tests that ReadableStream.prototype.pipeThrough operates
generically on its arguments. Add tests that it performs brand checks on
|this|, |readable| and |writable|, and throws for other precondition
failures.

Also verify that it *doesn't* call pipeTo().

Also verify that preventClose, preventCancel and preventAbort work,
since we can no longer test that it passes through to pipeTo().

Also change the expected length of the function from 2 to 1 to reflect
that the options argument is optional.

Corresponding standard changes are at
whatwg/streams#966.
@ricea ricea merged commit b494f35 into whatwg:master Nov 27, 2018
@ricea ricea deleted the pipethrough-brand-check branch November 27, 2018 14:27
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Dec 11, 2018
…ough() having a brand check, a=testonly

Automatic update from web-platform-tests
ReadableStream: modify tests for pipeThrough() having a brand check (#14193)

Remove tests that ReadableStream.prototype.pipeThrough operates
generically on its arguments. Add tests that it performs brand checks on
|this|, |readable| and |writable|, and throws for other precondition
failures.

Also verify that it *doesn't* call pipeTo().

Also verify that preventClose, preventCancel and preventAbort work,
since we can no longer test that it passes through to pipeTo().

Also change the expected length of the function from 2 to 1 to reflect
that the options argument is optional.

Corresponding standard changes are at
whatwg/streams#966.

--

wpt-commits: 4606e75ca8cd69830223f02e0fbd46fc160f431f
wpt-pr: 14193
xeonchen pushed a commit to xeonchen/gecko that referenced this pull request Dec 11, 2018
…ough() having a brand check, a=testonly

Automatic update from web-platform-tests
ReadableStream: modify tests for pipeThrough() having a brand check (#14193)

Remove tests that ReadableStream.prototype.pipeThrough operates
generically on its arguments. Add tests that it performs brand checks on
|this|, |readable| and |writable|, and throws for other precondition
failures.

Also verify that it *doesn't* call pipeTo().

Also verify that preventClose, preventCancel and preventAbort work,
since we can no longer test that it passes through to pipeTo().

Also change the expected length of the function from 2 to 1 to reflect
that the options argument is optional.

Corresponding standard changes are at
whatwg/streams#966.

--

wpt-commits: 4606e75ca8cd69830223f02e0fbd46fc160f431f
wpt-pr: 14193
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Dec 11, 2018
…ough() having a brand check, a=testonly

Automatic update from web-platform-tests
ReadableStream: modify tests for pipeThrough() having a brand check (#14193)

Remove tests that ReadableStream.prototype.pipeThrough operates
generically on its arguments. Add tests that it performs brand checks on
|this|, |readable| and |writable|, and throws for other precondition
failures.

Also verify that it *doesn't* call pipeTo().

Also verify that preventClose, preventCancel and preventAbort work,
since we can no longer test that it passes through to pipeTo().

Also change the expected length of the function from 2 to 1 to reflect
that the options argument is optional.

Corresponding standard changes are at
whatwg/streams#966.

--

wpt-commits: 4606e75ca8cd69830223f02e0fbd46fc160f431f
wpt-pr: 14193
mykmelez pushed a commit to mykmelez/gecko that referenced this pull request Dec 12, 2018
…ough() having a brand check, a=testonly

Automatic update from web-platform-tests
ReadableStream: modify tests for pipeThrough() having a brand check (#14193)

Remove tests that ReadableStream.prototype.pipeThrough operates
generically on its arguments. Add tests that it performs brand checks on
|this|, |readable| and |writable|, and throws for other precondition
failures.

Also verify that it *doesn't* call pipeTo().

Also verify that preventClose, preventCancel and preventAbort work,
since we can no longer test that it passes through to pipeTo().

Also change the expected length of the function from 2 to 1 to reflect
that the options argument is optional.

Corresponding standard changes are at
whatwg/streams#966.

--

wpt-commits: 4606e75ca8cd69830223f02e0fbd46fc160f431f
wpt-pr: 14193
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 3, 2019
…ough() having a brand check, a=testonly

Automatic update from web-platform-tests
ReadableStream: modify tests for pipeThrough() having a brand check (#14193)

Remove tests that ReadableStream.prototype.pipeThrough operates
generically on its arguments. Add tests that it performs brand checks on
|this|, |readable| and |writable|, and throws for other precondition
failures.

Also verify that it *doesn't* call pipeTo().

Also verify that preventClose, preventCancel and preventAbort work,
since we can no longer test that it passes through to pipeTo().

Also change the expected length of the function from 2 to 1 to reflect
that the options argument is optional.

Corresponding standard changes are at
whatwg/streams#966.

--

wpt-commits: 4606e75ca8cd69830223f02e0fbd46fc160f431f
wpt-pr: 14193

UltraBlame original commit: fcc10971a6e8c63b0ae33f833e472ba7459fd202
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 3, 2019
…ough() having a brand check, a=testonly

Automatic update from web-platform-tests
ReadableStream: modify tests for pipeThrough() having a brand check (#14193)

Remove tests that ReadableStream.prototype.pipeThrough operates
generically on its arguments. Add tests that it performs brand checks on
|this|, |readable| and |writable|, and throws for other precondition
failures.

Also verify that it *doesn't* call pipeTo().

Also verify that preventClose, preventCancel and preventAbort work,
since we can no longer test that it passes through to pipeTo().

Also change the expected length of the function from 2 to 1 to reflect
that the options argument is optional.

Corresponding standard changes are at
whatwg/streams#966.

--

wpt-commits: 4606e75ca8cd69830223f02e0fbd46fc160f431f
wpt-pr: 14193

UltraBlame original commit: e1782a85a325a130ee1dd69b603f3015d5090ed1
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 3, 2019
…ough() having a brand check, a=testonly

Automatic update from web-platform-tests
ReadableStream: modify tests for pipeThrough() having a brand check (#14193)

Remove tests that ReadableStream.prototype.pipeThrough operates
generically on its arguments. Add tests that it performs brand checks on
|this|, |readable| and |writable|, and throws for other precondition
failures.

Also verify that it *doesn't* call pipeTo().

Also verify that preventClose, preventCancel and preventAbort work,
since we can no longer test that it passes through to pipeTo().

Also change the expected length of the function from 2 to 1 to reflect
that the options argument is optional.

Corresponding standard changes are at
whatwg/streams#966.

--

wpt-commits: 4606e75ca8cd69830223f02e0fbd46fc160f431f
wpt-pr: 14193

UltraBlame original commit: fcc10971a6e8c63b0ae33f833e472ba7459fd202
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 3, 2019
…ough() having a brand check, a=testonly

Automatic update from web-platform-tests
ReadableStream: modify tests for pipeThrough() having a brand check (#14193)

Remove tests that ReadableStream.prototype.pipeThrough operates
generically on its arguments. Add tests that it performs brand checks on
|this|, |readable| and |writable|, and throws for other precondition
failures.

Also verify that it *doesn't* call pipeTo().

Also verify that preventClose, preventCancel and preventAbort work,
since we can no longer test that it passes through to pipeTo().

Also change the expected length of the function from 2 to 1 to reflect
that the options argument is optional.

Corresponding standard changes are at
whatwg/streams#966.

--

wpt-commits: 4606e75ca8cd69830223f02e0fbd46fc160f431f
wpt-pr: 14193

UltraBlame original commit: e1782a85a325a130ee1dd69b603f3015d5090ed1
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 3, 2019
…ough() having a brand check, a=testonly

Automatic update from web-platform-tests
ReadableStream: modify tests for pipeThrough() having a brand check (#14193)

Remove tests that ReadableStream.prototype.pipeThrough operates
generically on its arguments. Add tests that it performs brand checks on
|this|, |readable| and |writable|, and throws for other precondition
failures.

Also verify that it *doesn't* call pipeTo().

Also verify that preventClose, preventCancel and preventAbort work,
since we can no longer test that it passes through to pipeTo().

Also change the expected length of the function from 2 to 1 to reflect
that the options argument is optional.

Corresponding standard changes are at
whatwg/streams#966.

--

wpt-commits: 4606e75ca8cd69830223f02e0fbd46fc160f431f
wpt-pr: 14193

UltraBlame original commit: fcc10971a6e8c63b0ae33f833e472ba7459fd202
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 3, 2019
…ough() having a brand check, a=testonly

Automatic update from web-platform-tests
ReadableStream: modify tests for pipeThrough() having a brand check (#14193)

Remove tests that ReadableStream.prototype.pipeThrough operates
generically on its arguments. Add tests that it performs brand checks on
|this|, |readable| and |writable|, and throws for other precondition
failures.

Also verify that it *doesn't* call pipeTo().

Also verify that preventClose, preventCancel and preventAbort work,
since we can no longer test that it passes through to pipeTo().

Also change the expected length of the function from 2 to 1 to reflect
that the options argument is optional.

Corresponding standard changes are at
whatwg/streams#966.

--

wpt-commits: 4606e75ca8cd69830223f02e0fbd46fc160f431f
wpt-pr: 14193

UltraBlame original commit: e1782a85a325a130ee1dd69b603f3015d5090ed1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants