我用process.on "uncaughtException"
. 有时我会多次调用它,因为不是微不足道的模块系统。所以我收到警告:
(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
我的代码:
var onError = function (){
if (true) // how to check if I allready set uncaughtException event?
{
process.on ("uncaughtException", function (err) {
console.log ("uncaughtException");
throw err;
}
);
}
};
为了模拟几个调用,我使用循环:
var n = 12;
for (var i = n - 1; i >= 0; i--) {
onError();
};
那么如何检查我是否已经设置了uncaughtException
事件?