Skip to content

[streams] _flush not being called #53

Closed
@missinglink

Description

@missinglink

In the following testcase the _flush callback is not being called after stream.end().

Simply removing the stream.write(null); line works fine.

Is it possible to end a stream with stream.write(null) and stream.end() or only the latter.

If so, why does stream.write(null) prevent stream.end() from triggering _flush?

var Transform = require('readable-stream/transform'),
    inherits  = require('util').inherits;

function MyTransform(opts){
  Transform.call(this, opts);
}

inherits(MyTransform, Transform);

MyTransform.prototype._transform = function( chunk, enc, next ){
  console.log('.');
  next();
};

MyTransform.prototype._flush = function(){
  console.log('END');
};

// ---

var stream = new MyTransform({ objectMode: true });

stream.write({ a: 'b' });
stream.write(null);
stream.end();

same behaviour on v0.11.14 and v0.10.33

ref: #89

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