I'm using gulpjs to bundle sets of css files. Each set gets bundled into its own file, so my code looks something like:
var es = require('event-stream');
gulp.task("bundle", function(){
var streams = [];
for(var i in sets) {
var set = sets[i];
var stream = gulp.src(set.sources)
.pipe(...)
.pipe(gulp.dest(set.destination));
streams.push(stream);
}
var merged = es.concat.apply(es, streams);
return merged;
});
So it's been working fine, but now my bundles have gotten big enough that I see the following error:
(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
I've tried to apply answers like this and this but I can't seem to figure out where to call setMaxListeners(0).
How do I call setMaxListeners when I'm merging streams?
It looks like the concern is with the event-stream module (see this issue).
For now, I was able to suppress the issue with this line of code. Of course, this sets the max globally which is not ideal.
require('events').EventEmitter.prototype._maxListeners = 30;
It appears that the issue will be eventually resolved in stream-combiner which is a dependency of event-stream.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With