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

Possible EventEmitter memory leak detected #14

Open
honkmaster opened this issue Mar 21, 2018 · 4 comments · May be fixed by #15
Open

Possible EventEmitter memory leak detected #14

honkmaster opened this issue Mar 21, 2018 · 4 comments · May be fixed by #15

Comments

@honkmaster
Copy link

honkmaster commented Mar 21, 2018

I am using this component with homebridge-mi-flower-care. After some time this error appears in the log and no updates are received subsequently:

(node) warning: possible EventEmitter memory leak detected. 11 servicesDiscover listeners added. Use emitter.setMaxListeners() to increase limit.

Do you have any idea?

Maybe it is related to the following issues: noble/noble#480

@honkmaster
Copy link
Author

honkmaster commented Mar 21, 2018

Additionally. Why are you missing noble.stopScanning(); in line 109ff. The demo suggests:

if (state === 'poweredOn') {
  noble.startScanning();
} else {
  noble.stopScanning();
}

@honkmaster
Copy link
Author

Third related question. In The demo the call stopScanning in discover, such as:

...
noble.on('discover', function(peripheral) {
  // we found a peripheral, stop scanning
  noble.stopScanning();
...

Why is this missing here?

@demirhanaydin
Copy link
Owner

Instead of deciding when to start or stop scanning inside the library, I just handoff this job to the library user. There is a delegated method called stopScanning here which does exactly what you send. In this way, you can decide when to start or stop related to your usage. I also mentioned it in the readme under the basic usage.

For the first question related to memory leak, I don't have clue right now. I haven't seen it before. I'll try to reproduce but would be nice if you could try the suggested branch in the thread and give some feedbacks.

@apla
Copy link

apla commented Nov 25, 2018

I have the same issue. On my mac adapter state is unknown, so library won't work. I've added logging of the noble.state:

node /usr/local/lib/node_modules/node-mi-flora/examples/basic.js 
unknown
every 15 seconds, rescan devices
unknown
every 15 seconds, rescan devices
unknown
every 15 seconds, rescan devices
unknown
every 15 seconds, rescan devices
unknown
every 15 seconds, rescan devices
unknown
every 15 seconds, rescan devices
unknown
every 15 seconds, rescan devices
unknown
every 15 seconds, rescan devices
unknown
every 15 seconds, rescan devices
unknown
every 15 seconds, rescan devices
unknown
(node:34922) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 stateChange listeners added. Use emitter.setMaxListeners() to increase limit

apla added a commit to apla/node-mi-flora that referenced this issue Nov 25, 2018
@apla apla linked a pull request Nov 25, 2018 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants