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

es.split breaks pipe chain? #67

Closed
kevzettler opened this Issue Jul 21, 2014 · 1 comment

Comments

Projects
None yet
2 participants
@kevzettler

kevzettler commented Jul 21, 2014

I have a custom stream that looks like this

function QueryFormatStream(){}
util.inherits(QueryFormatStream, Stream);

QueryFormatStream.prototype.write = function(query){
  console.log("we got query", query);
  this.emit('data', query);
};

QueryFormatStream.prototype.end = function(){
  this.emit('end');
};

module.exports = QueryFormatStream;

I have a pipe chain that looks like:

  var stream = fs.createReadStream(file_path)
                 .pipe(zlib.createGunzip())
                 .pipe(es.split())
                 .pipe(new QueryFormatStream())
                 .pipe(process.stdout)

running the stream like this produces no output and the console log statement in QueryFormatStream never gets called.

However calling it like so, without the QueryFormatStream correctly pipes it to process.stdout

  var stream = fs.createReadStream(file_path)
                 .pipe(zlib.createGunzip())
                 .pipe(es.split())
                 .pipe(process.stdout)
@dominictarr

This comment has been minimized.

Owner

dominictarr commented Jul 21, 2014

That is not the right way to create a stream. If you are making a classic stream you also need to set
readable and writable properties (see the node docs) but simplest is just to use my through module or rvagg's through2.

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