Skip to content

Allow to await writable streams #19068

@targos

Description

@targos

With async iterators, we can use synchronous-looking code to consume readable streams.
There is no equivalent for writable streams in Node core.

Example use case:

const fs = require('fs');
const zlib = require('zlib');

(async () => {
  const read = fs.createReadStream('data.txt.gz');
  const gunzip = zlib.createGunzip();
  const write = fs.createWriteStream('data.txt');

  await read.pipe(gunzip).pipe(write);
})();

This would resolve when write ends or reject if an error occurs.

Prior art:

/cc @nodejs/streams @mcollina

Metadata

Metadata

Assignees

No one assigned

    Labels

    promisesIssues and PRs related to ECMAScript promises.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