Skip to content

Commit d07dd31

Browse files
mcollinatargos
authored andcommittedApr 18, 2020
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 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

+19
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)
Please sign in to comment.