mikeatlas/realtime-server

Possible EventEmitter memory leak

Closed this issue · 3 comments

Using your node realtime server and I got this warning. Could be a bug?

(node) warning: possible EventEmitter memory leak detected. 11 message listeners added. Use emitter.setMaxListeners() to increase limit.

Well, it's just a warning, but truthfully my realtime-server is just an example, and I've not stress/load tested it throughly. There's plenty of discussion of this on StackOverflow and Socket.io's repository. You can set a higher number, or 0 to squash the warning message with process.setMaxListeners(0). Truthfully, leaking event emitter memory with too many listeners is a red-herring here, as some people claim it's not always a problem and the warning is a bit too conservative a default warning: nodejs/node-v0.x-archive#5108 (comment)

For what it's worth, if you want to work on a PR and detect disconnects which also remove event listeners from the emitters, feel free!

http://www.jongleberry.com/understanding-possible-eventemitter-leaks.html

Hi Mike,
I've just submitted my edits to solve the warning thanks to your suggestions.