-
Notifications
You must be signed in to change notification settings - Fork 3.1k
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
Streams: Add/update WPTs with AbortSignal's abort reason #31400
Streams: Add/update WPTs with AbortSignal's abort reason #31400
Conversation
streams/piping/abort.any.js
Outdated
assert_equals(rs.events[0], 'cancel', 'first event should be cancel'); | ||
assert_equals(rs.events[1].name, reason, 'the argument to cancel should be reason'); | ||
}, 'an aborted signal should cause the writable stream to reject with the signal\'s abort reason'); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we want to have a test for the case where the pipeTo operation is aborted after it started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other tests in this file already handle such cases. However, they always call abortController.abort()
. Should we parameterize some of these tests, so you can run them with abort()
or with abort(reason)
? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a fair point. A lot of the tests are either of the form "prevent... should prevent ....", "abort signal takes priority over ...", or "abort should do nothing after ..." which IIUC doesn't really make sense to test for the abort reason specifically. I've looked through the rest and tried parameterizing a few that seemed useful to me, but if you think there's any others I should do as well, please let me know :)
streams/piping/abort.any.js
Outdated
ws.getWriter().closed.catch(e => { | ||
assert_equals(e, error, 'the writable should be errored with the same object'); | ||
for (const reason of [null, undefined, error1]) { | ||
promise_test(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about making this an async function?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kept the tests using Promise chains to stay consistent because all of the other tests in the file also used them. Although I agree using async/await is slightly more readable, would it be weird if some tests use async/await, while the rest still have Promise chains? (just wondering because I'm not sure what the norm is)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nevermind, I've made it an async function now, but if you think I should change it back, please let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would it be weird if some tests use async/await, while the rest still have Promise chains?
I don't think that's a problem. @ricea do you have any opinions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually just talked to Adam offline, and he mentioned preferring async/await in newer tests now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Thank you for reviewing! |
See whatwg/streams#1182 for the accompanying spec change.
This PR updates the existing aborting test cases to check the
ctrl.signal.reason
again, which was initially removed in #31293 whenabortReason
was removed from the spec.I've also parameterized a few test cases to check the AbortSignal's abort reason is properly used in
rs.pipeTo()
calls.See whatwg/streams#1182 for the accompanying spec change.
/cc @yutakahirano, @MattiasBuelens