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 <[email protected]>
Reviewed-By: Anatoli Papirovski <[email protected]>
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Rich Trott <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
  • Loading branch information
mcollina authored and codebytere committed Feb 17, 2020
1 parent 538582b commit 80e75ab
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 80e75ab

Please sign in to comment.