async-listener
async-listener copied to clipboard
warning: possible EventEmitter memory leak detected
Hello, I'm getting the following warning when testing my app:
(node) warning: possible EventEmitter memory leak detected. 11 connection listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
at Server.addListener (events.js:239:17)
at Server._listen2 ([...]\node_modules\loopback\node_modules\continuation-local-storage\node_modules\async-listener\index.js:65:10)
at listen (net.js:1270:10)
at Server.listen (net.js:1366:5)
at Test.serverAddress ([...]\node_modules\supertest\lib\test.js:56:33)
at new Test ([...]\node_modules\supertest\lib\test.js:36:12)
at Object.obj.(anonymous function) [as post] ([...]\node_modules\supertest\index.js:25:14)
at test ([...]\test\models\userTest.js:264:10)
at wrappedPromise.propagateAslWrapper ([...]\node_modules\loopback\node_modules\continuation-local-storage\node_modules\async-listener\index.js:375:23)
at wrappedPromise.<anonymous> ([...]\node_modules\loopback\node_modules\continuation-local-storage\node_modules\async-listener\glue.js:188:31)
at wrappedPromise.proxyWrapper [as __asl_wrapper] ([...]\node_modules\loopback\node_modules\continuation-local-storage\node_modules\async-listener\index.js:382:29)
at [...]\node_modules\loopback\node_modules\continuation-local-storage\node_modules\async-listener\index.js:402:26
at process._tickDomainCallback (node.js:411:9)
at process.<anonymous> ([...]\node_modules\loopback\node_modules\continuation-local-storage\node_modules\async-listener\index.js:19:15)
Should the listener allocated on line 65 be deallocated in your library or this problem may come from the package that is using this library?
@DiogoDoreto did you find a solution/workaround for this?
@nicolasgramlich No, I haven't found any. It isn't critical on my case because it isn't interfering on the results of my tests, it's just an annoying message.
Both this issue and #29 are producing the same error and both have stack traces pointing to loopback and supertest. I suspect this has something to do with how loopback uses express and that breaks how supertest interacts with it. I'll have to investigate further, though I probably won't have time to look into it for a couple days.
This may also be an issue with loopback itself. If you haven't already, I'd recommend bringing this issue to their attention.
I also have problem with this... I also use Loopback and it only happens when I do supertest.agent(app). Someone really needs to figure out whats going on... For now, I'm just not using supertest.agent and it works fine.
Don't know if this helps anyone, but I ran into this in our app that uses continuation-local-storage and worked around it by mocking it with this mock:
export default {
getNamespace: (name) => namespaces[name] || getNamespace(),
createNamespace: (name) => {
namespaces[name] = getNamespace()
return namespaces[name]
},
}
const getNamespace = () => ({
get: () => {},
set: () => {},
run: (fn) => { fn() },
bindEmitter: () => {},
})
const namespaces = {}
btw I'm not using loopback.
same issue here