Skip to content

Commit

Permalink
stream: add regression test for async iteration completion
Browse files Browse the repository at this point in the history
A test was missing for an async iterator created after the stream
had emitted 'close'. This was regressed by #31314.

See: #31314

PR-URL: #31508
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
  • Loading branch information
mcollina authored and Trott committed Jan 29, 2020
1 parent 2cd9892 commit 24e81d7
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions test/parallel/test-stream-readable-async-iterators.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,5 +610,24 @@ async function tests() {
p.then(common.mustCall()).catch(common.mustNotCall());
}

{
// AsyncIterator should finish correctly if destroyed.

const r = new Readable({
objectMode: true,
read() {
}
});

r.destroy();
r.on('close', () => {
const it = r[Symbol.asyncIterator]();
const next = it.next();
next
.then(common.mustCall(({ done }) => assert.strictEqual(done, true)))
.catch(common.mustNotCall());
});
}

// To avoid missing some tests if a promise does not resolve
tests().then(common.mustCall());

0 comments on commit 24e81d7

Please sign in to comment.