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 TransformStreamDefaultController terminate() method #818

Merged
merged 2 commits into from Oct 3, 2017

Conversation

ricea
Copy link
Collaborator

@ricea ricea commented Oct 2, 2017

Replace close() with terminate(). In addition to closing the readable
side, terminate() also errors the writable side. This stops data from
being produced after we are no longer interested in it.

Modify existing tests to handle the new method, and add tests for the new
functionality.

Closes #774.

Replace close() with terminate(). In addition to closing the readable
side, terminate() also errors the writable side. This stops data from
being produced after we are no longer interested in it.

Modify existing tests to handle the new method, and add tests for the new
functionality.

Closes whatwg#774.
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.

I think this looks good, but it brought up some larger questions for me about throwing exceptions from controller methods. Maybe you have that all in hand already and I just need to read the code more closely...

});
return Promise.all([
promise_rejects(t, new TypeError(), ts.writable.abort(), 'abort() should reject with a TypeError'),
promise_rejects(t, error1, ts.readable.cancel(), 'cancel() should reject with error1')
Copy link
Member

Choose a reason for hiding this comment

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

Should we test more than .cancel() to test if it's errored properly?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

.cancel() is actually pretty specific. I added reader.closed to the tests just to be sure. I don't want to get into testing Readablestream itself here.

new TransformStream({
start(controller) {
controller.terminate();
assert_throws(new TypeError(), () => controller.error(error1), 'error() should throw');
Copy link
Member

Choose a reason for hiding this comment

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

Opened #821.

In general, have we tested/are we OK with the behavior for when controller methods throw? I think a guiding principle is that you shouldn't throw if it's not "your fault", e.g. if someone using the public API of the stream can transition the state in some way as to cause an exception. Does that sound familiar from previous discussions? Are we following it here, e.g. if the writable side is aborted or the readable side canceled?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for bringing this up. I had forgotten about it actually.

I filed #822 to track the changes to transform stream.

@ricea ricea merged commit 31863aa into whatwg:master Oct 3, 2017
@ricea ricea deleted the transform-stream-terminate branch October 3, 2017 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

What should the behaviour of controller.close() be?
2 participants