Skip to content

Drain unpiped readable streams? #11

@pkozlowski-opensource

Description

@pkozlowski-opensource

So, I've got impression that we need to do the same fix as in the original orchestrator as discussed here: robrich/orchestrator#48 (comment)

Here is a simple reproduce scenario:

var Readable = require('stream').Readable;

var through = require('through2');
var asyncDone = require('async-done');

var rs = new Readable({objectMode: true});
var c = 0;
rs._read = function () {
  if (c++ < 100) {
    rs.push(c);
  } else {
    rs.push(null);
  }
};

asyncDone(function(){

  return rs.pipe(through.obj(function (chunk, enc, cb) {
    console.log(chunk);
    this.push(chunk);
    cb();
  }));

}, function(err, result){
  console.log(err, result);
});

In this scenario the node process will terminate after reading 16 items.

Now that we've got stream-consume as a separate module a fix would be trivial, happy to send a PR if this makes sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions