warning: possible EventEmitter memory leak detected
Closed this issue · 11 comments
I periodically encounter this warning, either when running the publish-relation example (haven't tried the react todos), or from run-tests.sh
I'm not certain that this is truly bad but one time I got it, it was accompanied by a pretty major delay in talking to the database.
I'd like to track the problem down but I'm still beginning with meteor. I'd be grateful for any clues.
Here is the log.
W20150923-12:25:46.222(-7)? (STDERR) (node) warning: possible EventEmitter memory leak detected. 11 listeners added. Use emitter.setMaxListeners() to increase limit.
W20150923-12:25:46.239(-7)? (STDERR) Trace
W20150923-12:25:46.240(-7)? (STDERR) at PgLiveQuery.addListener (events.js:160:15)
W20150923-12:25:46.240(-7)? (STDERR) at [object Object].PG.Query.observe (pg.js:30:10)
W20150923-12:25:46.240(-7)? (STDERR) at [object Object].accounts._server.publish.is_auto [as _handler] (packages/accounts-base/accounts_server.js:703:1)
W20150923-12:25:46.240(-7)? (STDERR) at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1675:1)
W20150923-12:25:46.240(-7)? (STDERR) at [object Object]._.extend._runHandler (packages/ddp-server/livedata_server.js:1006:1)
W20150923-12:25:46.240(-7)? (STDERR) at [object Object]._.extend._startSubscription (packages/ddp-server/livedata_server.js:825:1)
W20150923-12:25:46.240(-7)? (STDERR) at packages/ddp-server/livedata_server.js:407:1
W20150923-12:25:46.241(-7)? (STDERR) at Array.forEach (native)
W20150923-12:25:46.241(-7)? (STDERR) at Function._.each._.forEach (packages/underscore/underscore.js:105:1)
W20150923-12:25:46.241(-7)? (STDERR) at [object Object]._.extend.startUniversalSubs (packages/ddp-server/livedata_server.js:406:1)
W20150923-12:25:46.241(-7)? (STDERR) at [object Object]._.extend._setUserId (packages/ddp-server/livedata_server.js:800:1)
W20150923-12:25:46.242(-7)? (STDERR) at [object Object].setUserId [as _setUserId] (packages/ddp-server/livedata_server.js:666:1)
W20150923-12:25:46.242(-7)? (STDERR) at [object Object]._.extend.setUserId (packages/ddp-common/method_invocation.js:94:1)
W20150923-12:25:46.242(-7)? (STDERR) at AccountsServer.Ap._loginUser (packages/accounts-base/accounts_server.js:269:1)
W20150923-12:25:46.242(-7)? (STDERR) at AccountsServer.Ap._attemptLogin (packages/accounts-base/accounts_server.js:323:1)
W20150923-12:25:46.243(-7)? (STDERR) at [object Object].methods.login (packages/accounts-base/accounts_server.js:498:1)
W20150923-12:25:46.244(-7)? (STDERR) at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1675:1)
W20150923-12:25:46.244(-7)? (STDERR) at packages/ddp-server/livedata_server.js:704:1
W20150923-12:25:46.244(-7)? (STDERR) at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
W20150923-12:25:46.244(-7)? (STDERR) at packages/ddp-server/livedata_server.js:703:1
W20150923-12:25:46.244(-7)? (STDERR) at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
W20150923-12:25:46.244(-7)? (STDERR) at [object Object]._.extend.protocol_handlers.method (packages/ddp-server/livedata_server.js:702:1)
This is not a real leak. We should bump the max limit of listeners higher to avoid the message.
https://nodejs.org/api/events.html#events_emitter_setmaxlisteners_n
Should we set it to zero for unlimited or like 100?
And where in the PgLiveQuery class should we put it?
I noticed that this happens when switching from list to list more than 10 times. It seems like publications are not being torn down?
So maybe it is a leak?
I see this sometimes when there is no activity, and there has been nothing more than a single connected client doing a single sign-out/sign-in. I had assumed that it is related to the exception in setInterval callback issue (#26) though I have no real evidence other than one often immediately precedes the other in the logs. My ongoing meteor update efforts have also yielded some other funnies that may be related - unfortunately I didn't capture them. Will get back to you if and when I have any more info, but FWIW it smells like a real bug to me.
Oooh, looks like we should remove that event when the handle is stopped?
I don't know enough to be able to repond to that. However, it does look like there are issues with handles. My upgraded (hacked) to meteor 1.2 version of postgres-packages gives me this stuff about handles in the logs:
The handle(17) returned by watching /home/marc/proj/simian/meteor/postgres-packages/packages/accounts-base-pg-driver/package.js is the same with an already watched path(/home/marc/proj/simian/meteor/postgres-packages/examples/publish-relation/packages/accounts-base-pg-driver/package.js)
The handle(19) returned by watching /home/marc/proj/simian/meteor/postgres-packages/packages/accounts-base/package.js is the same with an already watched path(/home/marc/proj/simian/meteor/postgres-packages/examples/publish-relation/packages/accounts-base/package.js)
The handle(25) returned by watching /home/marc/proj/simian/meteor/postgres-packages/packages/accounts-password-pg-driver/package.js is the same with an already watched path(/home/marc/proj/simian/meteor/postgres-packages/examples/publish-relation/packages/accounts-password-pg-driver/package.js)
The handle(27) returned by watching /home/marc/proj/simian/meteor/postgres-packages/packages/accounts-password/package.js is the same with an already watched path(/home/marc/proj/simian/meteor/postgres-packages/examples/publish-relation/packages/accounts-password/package.js)
The handle(35) returned by watching /home/marc/proj/simian/meteor/postgres-packages/packages/accounts-ui-unstyled/package.js is the same with an already watched path(/home/marc/proj/simian/meteor/postgres-packages/examples/publish-relation/packages/accounts-ui-unstyled/package.js)
The handle(2) returned by watching /home/marc/proj/simian/meteor/postgres-packages/packages/bookshelf/package.js is the same with an already watched path(/home/marc/proj/simian/meteor/postgres-packages/examples/publish-relation/packages/bookshelf/package.js)
The handle(6) returned by watching /home/marc/proj/simian/meteor/postgres-packages/packages/pg/package.js is the same with an already watched path(/home/marc/proj/simian/meteor/postgres-packages/examples/publish-relation/packages/pg/package.js)
I can submit a PR to fix this. I fixed it in my local app.
yes please
Please do!