aarons22 / homebridge-bond

Homebridge plugin for Bond
MIT License
64 stars 31 forks source link

Crash "cannot read property 'power' of undefined" #153

Closed dxdc closed 3 years ago

dxdc commented 3 years ago

Describe the bug Periodic crashes (every few days) cause HB restarts.

[5/4/2021, 8:42:11 AM] [Bond] A request error occurred: undefined
TypeError: Cannot read property 'power' of undefined
    at GenericAccessory.updateState (/usr/lib/node_modules/homebridge-bond/dist/accessories/GenericAccessory.js:22:49)
    at /usr/lib/node_modules/homebridge-bond/dist/accessories/GenericAccessory.js:32:18
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
TypeError: Cannot read property 'power' of undefined
    at GenericAccessory.updateState (/usr/lib/node_modules/homebridge-bond/dist/accessories/GenericAccessory.js:22:49)
    at /usr/lib/node_modules/homebridge-bond/dist/accessories/GenericAccessory.js:32:18
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
abort(TypeError: Cannot read property 'power' of undefined). Build with -s ASSERTIONS=1 for more info.

Information (please complete the following information):

searls commented 3 years ago

I think I'm seeing the same thing. Just installed for the first time via HOOBS:

5/4/2021, 1:07:27 PM [Bond] Initializing Bond platform...
5/4/2021, 1:07:28 PM [Bond] 0 cached accessories were loaded
5/4/2021, 1:07:28 PM [Bond] Getting devices for this Bond (ZZDI37039)...
5/4/2021, 1:07:28 PM [Bond] 2 devices were found on this Bond (ZZDI37039).
5/4/2021, 1:07:28 PM [Bond] Attempting to add 2 devices that were not previously added.
5/4/2021, 1:07:38 PM [Bond] A request error occurred: undefined
5/4/2021, 1:07:38 PM [Bond] A request error occurred: undefined
5/4/2021, 1:07:38 PM [Bond] A request error occurred: undefined
5/4/2021, 1:07:38 PM [Bond] A request error occurred: undefined
5/4/2021, 1:07:38 PM [Bond] A request error occurred: undefined
5/4/2021, 1:07:38 PM [Bond] A request error occurred: undefined
5/4/2021, 1:07:38 PM [Bond] A request error occurred: undefined
5/4/2021, 1:07:38 PM [Bond] A request error occurred: undefined
5/4/2021, 1:07:38 PM [Bond] A request error occurred: undefined
5/4/2021, 1:07:38 PM [Bond] A request error occurred: undefined
5/4/2021, 1:07:38 PM [Bond] A request error occurred: undefined
5/4/2021, 1:07:38 PM [Bond] A request error occurred: undefined
5/4/2021, 1:07:38 PM [Bond] A request error occurred: undefined
5/4/2021, 1:07:38 PM [Bond] A request error occurred: undefined
5/4/2021, 1:07:38 PM [Bond] A request error occurred: undefined
5/4/2021, 1:07:38 PM [Bond] A request error occurred: undefined
5/4/2021, 1:07:38 PM [Bond] A request error occurred: undefined
5/4/2021, 1:07:38 PM [Bond] A request error occurred: undefined
5/4/2021, 1:07:38 PM [Bond] [Master Bedroom Fan Remote] actions: TurnOff,SetSpeed,SetDirection,ToggleLight,StartIncreasingBrightness,StartDecreasingBrightness,OEMTimer,OEMRandom,Stop,TogglePower,TurnOn,IncreaseSpeed,DecreaseSpeed,ToggleDirection,TurnLightOn,TurnLightOff
5/4/2021, 1:07:38 PM [Bond] Error getting devices: TypeError: Cannot read property 'action' of undefined
searls commented 3 years ago

Just pulled down the plugin and ran it locally against a fresh copy of homebridge (macOS, node 14) and couldn't replicate the problem against the same bridge

searls commented 3 years ago

Tried installing a fresh raspberry pi / homebridge image and set up homebridge UI and seeing similar errors:

[04/05/2021, 22:09:37] [Bond] Configuring Accessory: My Room Master Bedroom Fan Remote
[04/05/2021, 22:09:37] [Bond] [Master Bedroom Fan Remote] actions: TurnOff,SetSpeed,SetDirection,ToggleLight,StartIncreasingBrightness,StartDecreasingBrightness,OEMTimer,OEMRandom,Stop,TogglePower,TurnOn,IncreaseSpeed,DecreaseSpeed,ToggleDirection,TurnLightOn,TurnLightOff
[04/05/2021, 22:09:47] [Bond] A request error occurred: undefined
[04/05/2021, 22:09:47] [Bond] A request error occurred: undefined
[04/05/2021, 22:09:47] [Bond] A request error occurred: undefined
[04/05/2021, 22:09:47] [Bond] A request error occurred: undefined
[04/05/2021, 22:09:47] [Bond] A request error occurred: undefined
[04/05/2021, 22:09:47] [Bond] A request error occurred: undefined
[04/05/2021, 22:09:47] [Bond] A request error occurred: undefined
[04/05/2021, 22:09:47] [Bond] A request error occurred: undefined
[04/05/2021, 22:09:47] [Bond] A request error occurred: undefined
[04/05/2021, 22:09:47] [Bond] [Balcony Ceiling Fan Remote] actions: TurnOff,SetSpeed,SetDirection,ToggleLight,StartIncreasingBrightness,StartDecreasingBrightness,OEMTimer,OEMRandom,Stop,TogglePower,TurnOn,IncreaseSpeed,DecreaseSpeed,ToggleDirection,TurnLightOn,TurnLightOff
[04/05/2021, 22:09:47] [Bond] Error getting devices: TypeError: Cannot read property 'action' of undefined
searls commented 3 years ago

Weirdly, i've narrowed it down to the plugin working fine when homebridge is in debug mode, but failing (as shown above) when not in debug mode

searls commented 3 years ago

Just saw the error again, but this time it did trigger during debug mode so I could see the failed request:

[05/05/2021, 10:16:11] [Bond] A request error occurred: undefined
[05/05/2021, 10:16:11] [Bond] Error (185e4f38ad364002) [get http://192.168.1.229/v2/devices/11a547e8/commands/47e5f218] - {"message":"timeout of 10000ms exceeded","name":"Error","stack":"Error: timeout of 10000ms exceeded\n    at createError (/usr/local/lib/node_modules/homebridge-bond/node_modules/axios/lib/core/createError.js:16:15)\n    at RedirectableRequest.handleRequestTimeout (/usr/local/lib/node_modules/homebridge-bond/node_modules/axios/lib/adapters/http.js:280:16)\n    at RedirectableRequest.emit (events.js:315:20)\n    at Timeout._onTimeout (/usr/local/lib/node_modules/homebridge-bond/node_modules/follow-redirects/index.js:170:12)\n    at listOnTimeout (internal/timers.js:554:17)\n    at processTimers (internal/timers.js:497:7)","config":{"url":"http://192.168.1.229/v2/devices/11a547e8/commands/47e5f218","method":"get","data":"{}","headers":{"Accept":"application/json, text/plain, */*","BOND-Token":"615064ede36920b7","Bond-UUID":"185e4f38ad364002","Content-Type":"application/json;charset=utf-8","User-Agent":"axios/0.21.1","Content-Length":2},"transformRequest":[null],"transformResponse":[null],"timeout":10000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"axios-retry":{"retryCount":0,"lastRequestTime":1620224160997}},"code":"ECONNABORTED"}

New devices are failing to be added and picked up as a result, but existing devices continue to work

searls commented 3 years ago

There seems to be an underlying issue with the request, as increasing the timeout to 30s didn't fix it

aarons22 commented 3 years ago

@searls what bond firmware are you running? @dxdc reported this on a beta firmware, so I'm wondering if there is something going on there.

The changes from 3.2.6 and 3.2.8 only affected the fireplace accessory, so if it was running smoothly before on 3.2.6 (released on march 31), then I'm guessing it's related to bond firmware and the API potentially changing?

searls commented 3 years ago

I'm on Bond Bridge v2.17.4-1-g29bc8b4

aarons22 commented 3 years ago

Thanks @searls . I'm adding better logging for network failures in the upcoming release.

@dxdc out of curiosity, is your Bond using a static IP?

dxdc commented 3 years ago

@dxdc out of curiosity, is your Bond using a static IP?

Yes. I had to do that in order to use it in other contexts (e.g., homebridge-blinds plugin)

JeffGoldner commented 3 years ago

I'm seeing pretty much the same problem. It had been working yesterday when I got my new Bond Bridge. But I had to remove and re-add a fan that was not working in the Bond app. Got that sorted out, restarted the plug in and it errors out - sometimes with no devices recognized, sometimes one or two out of four.

I turned on Homebridge debug mode and everything is working now.

Same firmware v2.17.4-1-g29bc8b4. Reserved IP address although it has not changed after many reboots of the Bond so that wasn't the problem.

aarons22 commented 3 years ago

I'm seeing a theme here with a few other issues reported. Essentially, something is happening where the commands/{command_id} request fails, causing a cascading effect on the plugin. Hoping to narrow it down in this issue: https://github.com/aarons22/homebridge-bond/issues/173

Closing this one in favor of the conversation there