Skip to content

Commit 80e75ab

Browse files
mcollinacodebytere
authored andcommitted
stream: add regression test for async iteration completion
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]>
1 parent 538582b commit 80e75ab

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

test/parallel/test-stream-readable-async-iterators.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -610,5 +610,24 @@ async function tests() {
610610
p.then(common.mustCall()).catch(common.mustNotCall());
611611
}
612612

613+
{
614+
// AsyncIterator should finish correctly if destroyed.
615+
616+
const r = new Readable({
617+
objectMode: true,
618+
read() {
619+
}
620+
});
621+
622+
r.destroy();
623+
r.on('close', () => {
624+
const it = r[Symbol.asyncIterator]();
625+
const next = it.next();
626+
next
627+
.then(common.mustCall(({ done }) => assert.strictEqual(done, true)))
628+
.catch(common.mustNotCall());
629+
});
630+
}
631+
613632
// To avoid missing some tests if a promise does not resolve
614633
tests().then(common.mustCall());

0 commit comments

Comments
 (0)