Skip to content

Readable stream behavior in 0.10 #120

Closed
@zbjornson

Description

@zbjornson

(Context: Automattic/node-canvas#740 (comment))

Any chance anyone remembers behaviors/bugs in 0.10.x that cause stream.Readable to start emitting data as soon as .on("data", fn) is attached but before .on("end", fn)?

var stream = xx.createStream();
stream.on("data", function () { console.log("data emitted"); });
stream.on("end", function () { console.log("end emitted"); }); // won't be called unless moved before .on("data")

This behavior seems unique to 0.10 (not 0.12 or later) and unique to stream.Readable (not stream.Stream). I'm not sure if my usage of stream.Readable is causing this (e.g. https://github.com/Automattic/node-canvas/pull/740/files#diff-45eee70dc7ffb2bde8f118a35949d995). I think it can be fixed by wrapping the emitter in process.nextTick, but I would like to make sure that's not a fix for something I'm doing wrong. Thanks!

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