Auto Update Polling: Cannot read property 'mac' of undefined
Closed this issue · 4 comments
piemme commented
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.