mabunixda / node-red-contrib-nuki

node for nuki
MIT License
6 stars 9 forks source link

missing error handling #22

Closed kapet closed 2 years ago

kapet commented 3 years ago

My Nuki bridge occasionally responds with 'success: false' to lock status requests. (also reported here: https://developer.nuki.io/t/success-false-despite-internal-retry/10324 )

The nuki-bridge-api kind-of handles this by checking for success==true and throwing an error if it's getting a false. Unfortunately, this Node Red node isn't handling this error when it happens - the only thing I see is an error in the syslog: May 11 20:34:24 node-red Node-RED[2164]: Unhandled rejection (<{"success":false}>, no stack trace)

I've simply added this after the lockState().then(...) blocks (lines 199 and 209 in nuki.js): .catch(function(err) { msg.payload = {'error': 'failed sending lock action command'}; underControl.send(msg); return; });

With this I get a message out of the node so that I can retry :-)

I haven't seen it specifically but I suspect the lockAction() promise on line 194 could have the same problem.

mabunixda commented 3 years ago

@kapet do you implemented this in a fork? please open a PR for this change

kapet commented 2 years ago

has been fixed and works fine, nuki node emits a message with payload.error set to a string if this happens