Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream: async iterator stop read if destroyed #35640

Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion lib/internal/streams/readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions test/parallel/test-stream-readable-async-iterators.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ async function tests() {
});

const iter = Readable.prototype[Symbol.asyncIterator].call(stream);
await iter.next();
await iter.next();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was modified in the original PR, this PR helps bring it back to what it was.

await iter.next()
.then(common.mustNotCall())
.catch(common.mustCall((err) => {
Expand Down