Skip to content

Stream async iteration doesn't work with already closed streams #23891

Description

@TimothyGu
'use strict';

const { Readable } = require('stream');

const r = new Readable({
  objectMode: true,
  read() {
    this.push('asdf');
    this.push('hehe');
    this.push(null);
  }
});

(async () => {
  for await (const a of r) {
    console.log(a);
  }
  for await (const b of r) {
    console.log(b);
  }
  console.log('done');
})();

This prints

asdf
hehe

notably without the "done" line.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    streamIssues and PRs related to Node.js streams.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions