Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[0.9] Too many event handlers registered with VariableManager events #955

Closed
mwittig opened this issue Jul 28, 2016 · 9 comments
Closed

Comments

@mwittig
Copy link
Collaborator

mwittig commented Jul 28, 2016

Seems like there are too many event handlers registered with VariableManager events. I think we need to review this careefully.

See also: https://forum.pimatic.org/topic/2081/missing-property-allowedorigin

10:53:52.844 [pimatic] info: New device “Beweging N 2”…
(node) warning: possible EventEmitter memory leak detected. 101 variableRemoved listeners added. Use emitter.setMaxListeners() to increase limit.
Trace
at VariableManager.addListener (events.js:239:17)
at VariablePredicateHandler.PredicateHandler.dependOnVariable (/home/pi/pimatic-app/node_modules/pimatic/lib/predicates.coffee:63:23)
at VariablePredicateHandler.setup (/home/pi/pimatic-app/node_modules/pimatic/lib/predicates.coffee:625:10)
at /home/pi/pimatic-app/node_modules/pimatic/lib/rules.coffee:590:21
at RuleManager._addPredicateChangeListener (/home/pi/pimatic-app/node_modules/pimatic/lib/rules.coffee:587:9)
at /home/pi/pimatic-app/node_modules/pimatic/lib/rules.coffee:711:10
at tryCatcher (/home/pi/pimatic-app/node_modules/pimatic/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/home/pi/pimatic-app/node_modules/pimatic/node_modules/bluebird/js/release/promise.js:504:31)
at Promise._settlePromise (/home/pi/pimatic-app/node_modules/pimatic/node_modules/bluebird/js/release/promise.js:561:18)
at Promise._settlePromiseCtx (/home/pi/pimatic-app/node_modules/pimatic/node_modules/bluebird/js/release/promise.js:598:10)
at Async._drainQueue (/home/pi/pimatic-app/node_modules/pimatic/node_modules/bluebird/js/release/async.js:143:12)
at Async._drainQueues (/home/pi/pimatic-app/node_modules/pimatic/node_modules/bluebird/js/release/async.js:148:10)
at Immediate.Async.drainQueues [as _onImmediate] (/home/pi/pimatic-app/node_modules/pimatic/node_modules/bluebird/js/release/async.js:17:14)
at processImmediate [as _immediateCallback] (timers.js:383:17)
10:54:42.164 [pimatic-mobile-frontend] info: packing static assets
@mwittig mwittig changed the title [0.9] [0.9] Too many event handlers registered with VariableManager events Jul 28, 2016
@WimUtTwente
Copy link

Currently I am using 90 devices and 102 rules.

@mwittig
Copy link
Collaborator Author

mwittig commented Jul 28, 2016

OK, thanks. Seems like you're using a lot of variables as part of your rules :) Currently we have a limit of 100 event listeners per event source and it seems like you have more than 100 variable usages, e.g. some like "when $myDevice.attribute > 0 then ...". Before we increase the limit I think we need to check:

  • if multiple registrations occur from the same origin (this may be a bug)
  • give it some thought about whether or not we need a different concept for the interaction between the Rule and Variables Managers

@bstrebel
Copy link
Contributor

Run into the same warning with 110 devices and 100 rules. How can I increase the limit?

@mwittig
Copy link
Collaborator Author

mwittig commented Sep 19, 2016

Sorry, it is not configurable at the moment.

@mwittig mwittig self-assigned this Sep 19, 2016
@mwittig
Copy link
Collaborator Author

mwittig commented Sep 19, 2016

From the docs:
"Note, that this is not a hard limit. The EventEmitter instance will allow more listeners to be added but will output a trace warning to stderr indicating that a "possible EventEmitter memory leak" has been detected.".

I'll look into this soon.

@bstrebel
Copy link
Contributor

Thanks for the clarification. It would be great to have the limit either configurable or something like "self-adjusting" according to the number of devices and rules found in config.json

mwittig added a commit that referenced this issue Sep 20, 2016
@bstrebel
Copy link
Contributor

bstrebel commented Oct 8, 2016

Just updated to 0.9.34 and checked the new "defaultMaxListeners" settings: works like a charm. Thanks!

@mwittig
Copy link
Collaborator Author

mwittig commented Oct 8, 2016

You're welcome :) I am closing this now

@WimUtTwente
Copy link

Just updated to 0.9.34 with "defaultMaxListeners" : 300
no more error messages on startup verdwer everything works normal,
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants