How can I debug my application which throw this error:
(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxList
This is exactly what happened to me. For me, I nested an event listener within another event listener accidentally.
Look at your code and make sure you DO NOT have an event listener block WITHIN another event listener block for example(unless you are doing it on purpose):
socket.on('data', function(data) {
//code goes here
socket.on('close' , function() {
//code goes here
});
});
In the wrong example above, the socket.on ('close') listener should be OUTSIDE of the socket.on('data') block.
In my case when I received 5 data streams, the socket.on('close') listener is waiting for a close event to happen. When I close once, another 4th closing event would execute. This is clearly not what I wanted. This is due to the nature of Node.js which is non-blocking. It 'remembers' events due to the callback function.