Skip to content

Commit d07dd31

Browse files
mcollinatargos
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 717f9c5 commit d07dd31

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
@@ -527,5 +527,24 @@ async function tests() {
527527
p.then(common.mustCall()).catch(common.mustNotCall());
528528
}
529529

530+
{
531+
// AsyncIterator should finish correctly if destroyed.
532+
533+
const r = new Readable({
534+
objectMode: true,
535+
read() {
536+
}
537+
});
538+
539+
r.destroy();
540+
r.on('close', () => {
541+
const it = r[Symbol.asyncIterator]();
542+
const next = it.next();
543+
next
544+
.then(common.mustCall(({ done }) => assert.strictEqual(done, true)))
545+
.catch(common.mustNotCall());
546+
});
547+
}
548+
530549
// To avoid missing some tests if a promise does not resolve
531550
tests().then(common.mustCall());

0 commit comments

Comments
 (0)