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

MaxListenersExceededWarning: Possible EventEmitter memory leak detected when calling device::gatt() #76

Open
naugehyde opened this issue Oct 2, 2024 · 0 comments

Comments

@naugehyde
Copy link

Running the code below with appropriate command line args (mac_address and timeout. eg node test.js 'FF:FF:FF:FF:FF:FF' 15000) causes, after 10 trials in my case, the following warning to appear on the console repeatedly, one for each of the gatt server's primary service's characteristics:

(node:230077) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 {"path":"/org/bluez/hci0/dev_XX_XX_XX_XX_XX_XX/service000e/char00XX","interface":"org.freedesktop.DBus.Properties","member":"PropertiesChanged"} listeners added to [EventEmitter]. Use emitter.setMaxListeners() to increase limit


const {createBluetooth} = require('node-ble')
const {bluetooth, destroy} = createBluetooth()
const { argv } = require('node:process');


async function main(){

  const adapter = await bluetooth.defaultAdapter()
  const device = await adapter.waitDevice(argv[2])
  
  try{await adapter.startDiscovery()} catch{}
  var trials=0

  async function search(){
      await device.connect()
      console.log(`GATT trial #${++trials}...`)
      const gatt = await device.gatt()
      await device.disconnect()
 }

setInterval(() => {
  search()
},argv[3]);
search()
}
main()


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

No branches or pull requests

1 participant