This seems to be a common question on SO, but I've tried all of the suggestions and just can't seem to get past it. The common solution seems to be a strategically placed:
process.setMaxListeners(0);
But I just can't seem to figure out where to put it. Its happening in my test cases: https://github.com/socketwiz/swblog/blob/master/test/contact.js
It was fine at first but as I began adding more test cases it started producing the following error:
(node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
at process.EventEmitter.addListener (events.js:160:15)
at process.on.process.addListener (node.js:769:26)
at Object.module.exports [as shutdown] (/Users/socketwiz/Sites/swblog/node_modules/kraken-js/lib/middleware/shutdown.js:41:13)
at Object.proto._middleware (/Users/socketwiz/Sites/swblog/node_modules/kraken-js/lib/appcore.js:166:24)
at next (/Users/socketwiz/Sites/swblog/node_modules/kraken-js/lib/appcore.js:77:18)
at Object.configure (/Users/socketwiz/Sites/swblog/index.js:10:5)
at Object.proto._configure (/Users/socketwiz/Sites/swblog/node_modules/kraken-js/lib/appcore.js:85:28)
at Object.proto.init (/Users/socketwiz/Sites/swblog/node_modules/kraken-js/lib/appcore.js:35:14)
at create (/Users/socketwiz/Sites/swblog/node_modules/kraken-js/lib/appcore.js:258:13)
at Promise.apply (/Users/socketwiz/Sites/swblog/node_modules/kraken-js/node_modules/q/q.js:1122:26)
at Promise.promise.promiseDispatch (/Users/socketwiz/Sites/swblog/node_modules/kraken-js/node_modules/q/q.js:752:41)
at /Users/socketwiz/Sites/swblog/node_modules/kraken-js/node_modules/q/q.js:1337:14
at flush (/Users/socketwiz/Sites/swblog/node_modules/kraken-js/node_modules/q/q.js:108:17)
at process._tickDomainCallback (node.js:459:13)
It doesn't seem to be any particular test because if I comment a test that is failing, it will just move to a different test.
In an attempt to fix it I've tried setting:
server.setMaxListeners(0);
here: https://github.com/socketwiz/swblog/blob/master/test/contact.js#L21
I also tried setting
server.setMaxListeners(0);
here: https://github.com/socketwiz/swblog/blob/master/index.js#L15
But I just don't seem to be having any luck. Any ideas where I should put it, or is there a better solution? I'm using node v0.10.26. My entire project can be found here for reference: https://github.com/socketwiz/swblog
As best as I can tell everything is working and this is just a warning, but its kind of annoying :(