Skip to content

Commit

Permalink
Fix a flaky ReadableStream test
Browse files Browse the repository at this point in the history
Explicitly wait for the start promise instead of using a timeout.
  • Loading branch information
youennf authored and ddorwin committed Sep 13, 2016
1 parent d3c1091 commit 4d72571
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions streams/readable-streams/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,12 @@ promise_test(() => {
promise_test(() => {

let pullCount = 0;
const startPromise = Promise.resolve();

const rs = new ReadableStream({
start() {
return startPromise;
},
pull(c) {
// Don't enqueue immediately after start. We want the stream to be empty when we call .read() on it.
if (pullCount > 0) {
Expand All @@ -304,9 +308,9 @@ promise_test(() => {
}
});

return delay(1).then(() => {
return startPromise.then(() => {
assert_equals(pullCount, 1, 'pull should be called once start finishes');

}).then(() => {
const reader = rs.getReader();
const read = reader.read();
assert_equals(pullCount, 2, 'pull should be called when read is called');
Expand Down

0 comments on commit 4d72571

Please sign in to comment.