Dev Dev - 6 months ago 53
Node.js Question

possible EventEmitter memory leak detected

I am getting following warning:

(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
at EventEmitter.<anonymous> (events.js:139:15)
at EventEmitter.<anonymous> (node.js:385:29)
at Server.<anonymous> (server.js:20:17)
at Server.emit (events.js:70:17)
at HTTPParser.onIncoming (http.js:1514:12)
at HTTPParser.onHeadersComplete (http.js:102:31)
at Socket.ondata (http.js:1410:22)
at TCP.onread (net.js:354:27)

I wrote code like this in server.js:

function (req, res) { ... }).listen(3013);

How to fix this ?


This is explained in the manual:

What version of Node is this? What other code do you have? That isn't normal behavior.

In short, its: process.setMaxListeners(0);

Also see: node.js - request - How to “emitter.setMaxListeners()”?