Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Readable stream behavior in 0.10 #120

Closed
zbjornson opened this issue Mar 25, 2016 · 1 comment
Closed

Readable stream behavior in 0.10 #120

zbjornson opened this issue Mar 25, 2016 · 1 comment

Comments

@zbjornson
Copy link

(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!

@zbjornson
Copy link
Author

From nodejs/node-v0.x-archive#5865 (comment)

The other semantic change is that adding a readable event handler will not cause readable to be emitted until nextTick

Relevant diff:

nodejs/node-v0.x-archive@0f8de5e#diff-ba6a0df0f5212f5cba5ca5179e209a17L681
Notice .resume calls through a nextTick, whereas the removed emitDataEvents looks like it plowed straight through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant