-
Notifications
You must be signed in to change notification settings - Fork 161
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 @@asyncIterator to ReadableStream #980
Add @@asyncIterator to ReadableStream #980
Conversation
The WPT submodule hasn't yet been updated, so the tests are currently failing on Travis because of the "unexpected" The reference implementation passes all of the new tests locally. Even the dreaded |
1eb74e3
to
173af93
Compare
The tests have found a bug in the spec! 🎉 This test fails with the current reference implementation. When calling The problem is that function testIterator() {
return {
[Symbol.asyncIterator]() {
return {
async next() {
console.log('next() called');
return {done: true};
},
async return() {
console.log('return() called');
}
};
}
};
}
(async () => {
console.log('before');
for await (const chunk of testIterator()) {
console.log({chunk});
}
console.log('after');
})(); This logs:
Clearly, the To fix this, we need to change the return ReadableStreamDefaultReaderRead(reader)
.then(({ value, done }) => {
if (done) {
ReadableStreamReaderGenericRelease(reader);
}
return ReadableStreamCreateReadResult(value, done);
}); Or we could re-use the read result (although I don't know if this can cause issues?) to avoid creating an extra object: return ReadableStreamDefaultReaderRead(reader, true)
.then(result => {
if (result.done) {
ReadableStreamReaderGenericRelease(reader);
}
return result;
}); Similarly, the spec text should be updated to transform the returned promise with a fulfillment handler. |
Yep, agreed, we should fix that! This was my second point in #778 (comment) . |
All right, I'll fix it. Any preference on the style of the
Can we just check
|
I think we have to do it the long way. It would be weird if |
7a4527c
to
f1d85b9
Compare
I've pushed a commit to update WPT to the latest commit of the opened WPT PR, to check whether the new tests also pass on Travis. Once the WPT PR lands, I'll amend the commit to point to the merged commit in WPT. |
Aaaand the build fails on linter errors. Probably because I had to update I'll see if the linter config can be updated to better match our coding style. If not, I guess I can just |
490eed0
to
940353b
Compare
And now it's |
LGTM! Will let @ricea do the honors for merging tests and then spec. Thanks so much, @MattiasBuelens and @devsnek! |
Test async iteration of ReadableStream. Standard changes are in whatwg/streams#980.
Automatic update from web-platform-tests ReadableStream @@asyncIterator (#15097) Test async iteration of ReadableStream. Standard changes are in whatwg/streams#980. -- wpt-commits: de6f8fcf9b87e80811e9267a886cf891f6f864e0 wpt-pr: 15097
Automatic update from web-platform-tests ReadableStream @@asyncIterator (#15097) Test async iteration of ReadableStream. Standard changes are in whatwg/streams#980. -- wpt-commits: de6f8fcf9b87e80811e9267a886cf891f6f864e0 wpt-pr: 15097
Automatic update from web-platform-tests ReadableStream @@asyncIterator (#15097) Test async iteration of ReadableStream. Standard changes are in whatwg/streams#980. -- wpt-commits: de6f8fcf9b87e80811e9267a886cf891f6f864e0 wpt-pr: 15097
Automatic update from web-platform-tests ReadableStream @@asyncIterator (#15097) Test async iteration of ReadableStream. Standard changes are in whatwg/streams#980. -- wpt-commits: de6f8fcf9b87e80811e9267a886cf891f6f864e0 wpt-pr: 15097
Automatic update from web-platform-tests ReadableStream asyncIterator (#15097) Test async iteration of ReadableStream. Standard changes are in whatwg/streams#980. -- wpt-commits: de6f8fcf9b87e80811e9267a886cf891f6f864e0 wpt-pr: 15097 UltraBlame original commit: a3f2954c055c5c09fb25ea019b6efc555fcd127c
Automatic update from web-platform-tests ReadableStream asyncIterator (#15097) Test async iteration of ReadableStream. Standard changes are in whatwg/streams#980. -- wpt-commits: de6f8fcf9b87e80811e9267a886cf891f6f864e0 wpt-pr: 15097 UltraBlame original commit: a3f2954c055c5c09fb25ea019b6efc555fcd127c
Automatic update from web-platform-tests ReadableStream asyncIterator (#15097) Test async iteration of ReadableStream. Standard changes are in whatwg/streams#980. -- wpt-commits: de6f8fcf9b87e80811e9267a886cf891f6f864e0 wpt-pr: 15097 UltraBlame original commit: daffa4526e1850355356d0131230159b9eed8724
Automatic update from web-platform-tests ReadableStream asyncIterator (#15097) Test async iteration of ReadableStream. Standard changes are in whatwg/streams#980. -- wpt-commits: de6f8fcf9b87e80811e9267a886cf891f6f864e0 wpt-pr: 15097 UltraBlame original commit: a3f2954c055c5c09fb25ea019b6efc555fcd127c
Automatic update from web-platform-tests ReadableStream asyncIterator (#15097) Test async iteration of ReadableStream. Standard changes are in whatwg/streams#980. -- wpt-commits: de6f8fcf9b87e80811e9267a886cf891f6f864e0 wpt-pr: 15097 UltraBlame original commit: daffa4526e1850355356d0131230159b9eed8724
Automatic update from web-platform-tests ReadableStream asyncIterator (#15097) Test async iteration of ReadableStream. Standard changes are in whatwg/streams#980. -- wpt-commits: de6f8fcf9b87e80811e9267a886cf891f6f864e0 wpt-pr: 15097 UltraBlame original commit: daffa4526e1850355356d0131230159b9eed8724
Sorry for create noise here, does anyone know timeline for browers plan to support this? |
We've filed implementation bugs with all major browser vendors, see #778 (comment). From there, it's up to each individual browser vendor to implement this change as they see fit. You can star the Chromium issue and/or vote on the Firefox bug in order to let them know that you're interested in this feature. Or, if you're willing to put in the effort, you can contribute an implementation yourself. 😉 (Do post a comment on the bug first to inform them that you're working on it though, so they don't end up doing duplicate work.) |
This PR supersedes #954. So far, I've simply rebased @devsnek's changes onto
master
and fixed any conflicts.WPT PR: web-platform-tests/wpt#15097
Closes #778
Preview | Diff