Node.js event-stream: Where to setMaxListeners?

ⅰ亾dé卋堺 提交于 2019-12-02 04:39:12

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!