I'm using the following event emitter (and I need this functionality). My question is how to avoid the error.
It seems that I'm using event inside another event.
warning: possible EventEmitter memory leak detected. 11 AppUp listeners added. Use emitter.setMaxListeners() to increase limit.
I'm using node 0.12.7
This is the all module code:
var events = require('events');
var eventEmitter = new events.EventEmitter();
var run = function (req, res) {
host = req.headers.host.split(':')[0];
proxy.web(req, res, {
target: 'http://' + host + ':' + port
});
};
var runApp = function (req, res) {
appStatus.eventEmitter.on('AppUp', function () {
run(req, res);
});
if (model.get()) {
run(req, res);
}
}
module.exports = {
runApp: runApp
};
Is there a way to avoid this error?