-
Notifications
You must be signed in to change notification settings - Fork 106
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
Set highWaterMark to 16 in objectMode #18
Conversation
Here's the associated fix in node core from last August : |
Set highWaterMark to 16 in objectMode
@0.5.0 published, thanks @mafintosh |
Do I have to make any changes to my code because of this? I have this through2 object stream. The source is a LevelDB value stream (JSON). When I pipe it through the stream below it only processes exactly 16 objects, then stops and never triggers var full = through2.obj(function (data, enc, callback) {
geojson.geometry.coordinates.push([ data.longitude, data.latitude, data.altitude ]);
this.push(data);
callback();
}); |
@maxkueng are you piping it somewhere else? the I wonder if perhaps you're terminating on this stream and therefore don't want to be doing the |
@rvagg Wow, very fast reply skills! Thanks! I removed Do I understand correctly? The last stream I pipe through must be a writable stream or a through2 without |
yeah, you need your stream to terminate somewhere, usually with just a Writable stream that pushes it into the system (filesystem, network) or some kind of processing terminator. If you Also see https://github.com/brycebaril/node-terminus#terminusdevnulloptions for another option, that case is simply a For example, perhaps you wanted to use count-stream to do some counting but that's all you want to do with the data. count-stream is duplex and is intended to be placed in the middle of a processing chain, to make the data keep flowing you'd need to pipe that to a terminator like devnull. |
It makes totally sense now. I guess I just never ran in to the issue before where I didn't have a sink/terminating stream at the end. I also thought Thank you very much for the detailed reply and the module tips. Very appreciated. |
@rvagg is it worth adding (I'm happy to) this little gem to the README? I just spent a few hours trying to figure out what was going wrong in my implementation and this was the problem. |
@eddieajau yeah, you could, it trips people up all the time although it's not specific to through2 but we could help educate at least. |
Currently in node 0.10 hwm defaults to ~16000 objects when streaming in objectMode which means that backpressure will almost never happen.
This is fixed in node 0.12 where it will default to 16 in objectMode.
We can fix this now in through2 by merging this PR :)