ebaauw / homebridge-deconz

Homebridge plugin for deCONZ
Apache License 2.0
134 stars 7 forks source link

Possible EventEmitter memory leak detected #216

Closed ebaauw closed 1 month ago

ebaauw commented 5 months ago

From https://github.com/homebridge/homebridge/issues/3576

(node:1608878) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 initialised listeners added to [Gateway]. Use emitter.setMaxListeners() to increase limit
at genericNodeError (node:internal/errors:984:15)
at wrappedFn (node:internal/errors:538:14)
at _addListener (node:events:592:17)
at Gateway.addListener (node:events:610:10)
at Gateway.once (node:events:654:8)
at eventTargetAgnosticAddListener (node:events:1035:15)
at node:events:997:5
at new Promise ()
at Function.once (node:events:977:10)
at DeconzPlatform.foundGateway (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzPlatform.js:115:18)
(node:1608878) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 error listeners added to [Gateway]. Use emitter.setMaxListeners() to increase limit
at genericNodeError (node:internal/errors:984:15)
at wrappedFn (node:internal/errors:538:14)
at _addListener (node:events:592:17)
at Gateway.addListener (node:events:610:10)
at Gateway.once (node:events:654:8)
at node:events:1001:15
at new Promise ()
at Function.once (node:events:977:10)
at DeconzPlatform.foundGateway (/var/lib/homebridge/node_modules/homebridge-deconz/lib/DeconzPlatform.js:115:18)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
ebaauw commented 5 months ago

@djsmix could you please provide some info on your environment:

I think Homebridge deCONZ discovers one or more gateways for which it doesn't have an API key. The logic to handle that is probably somewhat flawed. The warning should go away once you unlock those gateway(s) or when you specify the gateway(s) you want to expose under hosts in config.json.

djsmix commented 5 months ago

deconz: upnp: request 1: M-SEARCH * deconz: upnp: listening on upnp deconz: phoscon.de: request 1: GET / deconz: upnp: found 00212EFFFF066A58 at 192.168.1.130 deconz: 192.168.1.130: request 1: GET /config deconz: 192.168.1.130: request 1: 200 OK deconz: phoscon.de: request 1: 200 OK deconz: phoscon.de: found 00212EFFFF066A58 at 192.168.1.130 deconz: upnp: search done { "192.168.1.130": { "apiversion": "1.16.0", "bridgeid": "00212EFFFF066A58", "datastoreversion": "93", "devicename": "ConBee II", "factorynew": false, "mac": "dc:a6:32:93:df:5a", "modelid": "deCONZ", "name": "Phoscon-GW", "replacesbridgeid": null, "starterkitid": "", "swversion": "2.26.3" } }

i only se this related to API:

Phoscon-GW: warning: 7F1EF14AA7: potentially stale api key: {"create date":"2023-12-30T23:13:11","last use date":"2023-12-30T23:16:12","name":"homebridge-deconz#raspberrypi"}

and i have already specified the host under config.json:

"name": "deCONZ", "hosts": [ "192.168.1.130" ], "_bridge": { "username": "xx.xx.xx.xx", "port": 58882 }, "platform": "deCONZ" }

ebaauw commented 5 months ago

Hm, only one gateway, and Homebridge deCONZ seems to connect to it just fine. Do you still get the "Possible EventEmitter memory leak detected" warnings?

Phoscon-GW: warning: 7F1EF14AA7: potentially stale api key: {"create date":"2023-12-30T23:13:11","last use date":"2023-12-30T23:16:12","name":"homebridge-deconz#raspberrypi"}

This typically means that you reset the Homebridge configuration (deleted cachedAccessoires), causing Homebridge deCONZ to obtain a new API key. deCONZ still has the previously used API key.

I would recommend running deCONZ and Homebrdige deCONZ on the same host (Raspberry Pi), so there's no network in between them.

djsmix commented 5 months ago

Aren't deCONZ and Homebridge deCONZ already on the same host?

And yes, i got the warning like in the morning

ebaauw commented 5 months ago

Aren't deCONZ and Homebridge deCONZ already on the same host?

In that case, you'd better specify the host in config.json as 127.0.0.1 or localhost.

And yes, i got the warning like in the morning

Did you restart Homebridge this morning?

I'm afraid I have no clue as to what's happening here. Could you please run Homebridge in DEBUG mode and capture the Homebridge log into a file, form the moment that Homebridge startups, up to and including when the warnings appear. Please attach the file (and don't copy/paste large amounts of text).