-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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 tests for ReadableStream.from() #27009
Add tests for ReadableStream.from() #27009
Conversation
50b37b0
to
549093b
Compare
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
Let's have tests for three horrible re-entrant cases:
reader.read()
is called insidenext()
.reader.cancel()
is called insidenext()
.reader.cancel()
is called insidereturn()
.
@ricea Great ideas! I've added tests for What would you want to see from a " If you mean let reader;
const iterable = {
async next() {
return await reader.read();
},
[Symbol.asyncIterator]: () => iterable
};
const rs = ReadableStream.from(iterable);
reader = rs.getReader();
await reader.read(); // stalls forever If you mean calling let reader;
const iterable = {
async next() {
reader.read(); // calls next() again, which calls read() again, repeating forever
return { value: 'a', done: false };
},
[Symbol.asyncIterator]: () => iterable
};
const rs = ReadableStream.from(iterable);
reader = rs.getReader();
await reader.read(); // blows up the microtask queue Or do we only want to call let nextCalls = 0;
let reader;
const iterable = {
async next() {
nextCalls += 1;
if (nextCalls === 1) {
reader.read();
}
return { value: 'a', done: false };
},
[Symbol.asyncIterator]: () => iterable
};
const rs = ReadableStream.from(iterable);
reader = rs.getReader();
await reader.read(); // calls next() twice
await reader.read(); // calls next() once |
New tests lgtm.
Yes. Calling it once should be sufficient to find any reentrancy bugs. |
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
602d2c2
to
8777511
Compare
8777511
to
43497da
Compare
0fcecbf
to
67fb793
Compare
67fb793
to
ea4ec04
Compare
@MattiasBuelens, can we merge the WPT tests? |
@youennf Yep, this is ready to go! |
Add tests for the new static method
ReadableStream.from()
.See whatwg/streams#1083 for the accompanying spec change.