Skip to content Skip to sidebar Skip to footer

Node.js Event-stream: Where To Setmaxlisteners?

I have searched and searched for this, to no avail. I've combed the web (including Stackoverflow), and the Node docs for an answer, and not found one---that worked (maybe that's ju

Solution 1:

In Node.js 0.12 (soon to be released) you'll be able to set the max for all emitters:

var events = require('events');
events.EventEmitter.defaultMaxListeners = 100;

More in the relevant commit.

Solution 2:

This is not a direct answer to your question, but you can pass an array of glob patterns to 'gulp.src()' instead of merging multiple 'gulp.src()'s. Doesn't it solve your problem?

https://github.com/gulpjs/gulp/blob/master/docs/API.md#gulpsrcglobs-options

EDIT

As a direct answer, the following worked for me:

var merged = eventStream.merge(...);
merged.setMaxListeners(0);
return merged.pipe(...);

While event listeners are added in the merge function, the listener count seems to be checked between ticks of the event loop. So we can setMaxListeners right after adding listeners.

Post a Comment for "Node.js Event-stream: Where To Setmaxlisteners?"