Skip to content

Commit 24e81d7

Browse files
mcollinaTrott
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 <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>
1 parent 2cd9892 commit 24e81d7

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

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

+19
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)