Skip to content

Change in stream behaviour in Node 4.4.5Β #7278

@davedoesdev

Description

@davedoesdev

Version: v4.4.5
Platform: Linux 4.2.0-36-generic #41-Ubuntu SMP Mon Apr 18 15:47:56 UTC 2016 i686 i686 i686 GNU/Linux
Subsystem: stream

I have the following test code:

var stream = require('stream'),
    util = require('util'),
    Writable = stream.Writable,
    PassThrough = stream.PassThrough;

function TestStream()
{
    Writable.call(this);
}

util.inherits(TestStream, Writable);

var count = 0;

TestStream.prototype._write = function (chunk, encoding, callback)
{
    count += 1;
    console.log("_write", chunk.length);
    if (count === 1)
    {
        pthru.push(new Buffer(64 * 1024));
    }
    callback();
};

var pthru = new PassThrough(),
    test = new TestStream();

pthru.pipe(test);

pthru.push(new Buffer(32 * 1024));
pthru.push(new Buffer(128 * 1024));

On 4.4.4, this prints:

_write 32768
_write 65536
_write 131072

On 4.4.5, this prints:

_write 32768
_write 65536

i.e. the final buffer gets lost. I believe this is because awaitDrain ends up as 2 but during clearBuffer only one drain event gets emitted.

I think the change in behaviour occurred due to #6023 - which seems sensible for the issue it was fixing.

My question is: which behaviour is correct? Is it supported to push onto the source stream during a write to the destination given a pipe has been set up between the two?

Metadata

Metadata

Assignees

Labels

streamIssues and PRs related to the stream subsystem.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions