Skip to content

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

@TimothyGu

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    streamIssues and PRs related to the stream subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions