hlapp/wirelesstags-js

Auto Update Polling: Cannot read property 'mac' of undefined

Closed this issue · 4 comments

Hi,
following the script in: examples/auto-update-polling.js
I obtain this output, with export DEBUG='*'

  read-sensors-upd connected to Wireless Tag cloud +0ms
  read-sensors-upd found manager tagmanagerA B97620E31946 +486ms
  read-sensors-upd found manager tagmanagerB 5042EBBE1772 +7ms
  read-sensors-upd found manager tagmanagerB 5042EBBE1772 +465ms
  read-sensors-upd TypeError: Cannot read property 'mac' of undefined
  read-sensors-upd     at req.then (/home/paolo/progetti/wireless-sensor-tag/node_modules/wirelesstags/lib/platform.js:370:58)
  read-sensors-upd     at process._tickCallback (internal/process/next_tick.js:109:7) +676ms
hlapp commented

That it throws a TypeError is a bug, thanks for reporting this @piemme. However, if that bug hadn't been there you would have still received an error, stating "Tag manager 5042EBBE1772 not found". It's not obvious why that was, but I suspect there may have been some kind of race condition. It looks like you have either 2 tag managers with the same MAC (which seems unlikely), or you have 2 tag managers but one of them is found twice. Which is odd.

I'll need to look into how I can make the code more thread safe. I'm not sure though that there isn't something else going on too that the code doesn't expect.

Thanks @hlapp for the response.
In this case I have two tag manager.

hlapp commented

FYI, the fix is released now as part of v0.7.0, which is also available from npm.

If you need this fixed for the v0.6.x release series, please let me know and I can try to backport it.

@hlapp, I'll use next release (v0.7.0).
No need for backport.
Thanks for fixing that.