Skip to content

Through2 should emit('end') after flush. #31

@bradobro

Description

@bradobro

Hey Rod,

I'm having problems getting a pipeline to shutdown so my program can exit. It looks like a my through2 pipe is not passing along the end event of it's readable stream. If I explicitly emit('end') in the flush function, all goes well:

var objectStreamInspector = through.obj(function(chunk, enc, transformCallback) {
    console.dir(chunk);
    this.push(chunk);
    transformCallback();
}, function flush(flushCallback){
    console.log('flushing');
    this.push(null);
    this.emit('end'); //if I don't do this, even though the input stream ends, this stream won't
    flushCallback();
});

It looks to me like transform streams are supposed to emit('end') after their flush. The stream (v0.10.33) docs say:

end is fired after all data has been output which is after the callback in _flush has been called.

I might be misunderstanding this.

--Brad Olson
ABS

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions