caseyjhol / node-red-contrib-tplink

A collection of Node-RED nodes for TP-Link Smart Home devices
https://www.npmjs.com/package/node-red-contrib-tplink-iot
MIT License
16 stars 15 forks source link

Memory Leak #31

Closed hufftheweevil closed 4 years ago

hufftheweevil commented 4 years ago

There is STILL a memory leak somehow. When the flows are redeployed or restarted, old versions of the client connection remain in tact and polling continues for them as well. I'm not sure why yet, since this bit of code

    node.on('close', function () {
      // NOTE: We reference node.client.devices here, just in case
      // there were devices initialized on this client that did not
      // make it into the node.devices map. This ensures no memory
      // leaking in case of bugs/errors.
      node.client.devices.forEach(device => {
        device.stopPolling()
        device.closeConnection()
      })
      node.client.stopDiscovery()
    })

was supposed to prevent that from happening. I'm working on a fix right now.

hufftheweevil commented 4 years ago

Found it. Fixed in https://github.com/caseyjhol/node-red-contrib-tplink/pull/32