Skip to content

Duplex seems to create unnecessary copies of Buffer data #162

Closed
@jamestalmage

Description

@jamestalmage

The assertion below fails in iojs >= 3.0.0, and Node >= 4.0.0. It passes in every earlier version I checked (0.8.28 to 2.5.0).

var stream = require('readable-stream');

var duplex = new stream.Duplex({
    write: function(chunk, enc, cb) {
        this.push(chunk);
        cb();
    },
    read: function() {}
});

var bufA = new Buffer('a');

var writable = new stream.Writable({
    write: function (chunk, enc, cb) {
        assert.strictEqual(chunk, bufA, 'should be the same instance');
    }
});

duplex.pipe(writable);

duplex.write(bufA);

It can be made to pass by setting readableObjectMode: true, but it is unclear to me why that would be necessary (or the implications it would have).

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