Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
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
  • Loading branch information
mcollina committed Jan 25, 2020
commit 638ba66e18b019bf5954cb61b9716e0b11338918
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 @@ -527,5 +527,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());