diff --git a/lib/internal/streams/readable.js b/lib/internal/streams/readable.js index 275fef2c676361..43b53447d8734e 100644 --- a/lib/internal/streams/readable.js +++ b/lib/internal/streams/readable.js @@ -1095,7 +1095,7 @@ async function* createAsyncIterator(stream) { try { while (true) { - const chunk = stream.read(); + const chunk = stream.destroyed ? null : stream.read(); if (chunk !== null) { yield chunk; } else if (errorEmitted) { diff --git a/test/parallel/test-stream-readable-async-iterators.js b/test/parallel/test-stream-readable-async-iterators.js index c2fde72457f22f..788ed8a8e2e0e0 100644 --- a/test/parallel/test-stream-readable-async-iterators.js +++ b/test/parallel/test-stream-readable-async-iterators.js @@ -43,8 +43,6 @@ async function tests() { }); const iter = Readable.prototype[Symbol.asyncIterator].call(stream); - await iter.next(); - await iter.next(); await iter.next() .then(common.mustNotCall()) .catch(common.mustCall((err) => {