i8beef / node-red-contrib-castv2

MIT License
22 stars 14 forks source link

Node Red appear to restart due to node error #12

Closed nygma2004 closed 4 years ago

nygma2004 commented 4 years ago

Let me say in the beginning, I am not sure if I read the logs correctly. My node-red restarts about once a day recently, and looking at the syslog I see the following:

Jan 15 18:50:05 OpenHAB Node-RED[26298]: 15 Jan 18:50:05 - [red] Uncaught Exception: Jan 15 18:50:05 OpenHAB Node-RED[26298]: 15 Jan 18:50:05 - TypeError: Cannot read property 'getAppAvailability' of null Jan 15 18:50:05 OpenHAB Node-RED[26298]: at PlatformSender.getAppAvailability (/home/pi/.node-red/node_modules/castv2-client/lib/senders/platform.js:78:17) Jan 15 18:50:05 OpenHAB Node-RED[26298]: at node.client.connect (/home/pi/.node-red/node_modules/node-red-contrib-castv2/castv2-sender.js:219:33) Jan 15 18:50:05 OpenHAB Node-RED[26298]: at Client. (/home/pi/.node-red/node_modules/castv2-client/lib/senders/platform.js:61:5) Jan 15 18:50:05 OpenHAB Node-RED[26298]: at Object.onceWrapper (events.js:286:20) Jan 15 18:50:05 OpenHAB Node-RED[26298]: at Client.emit (events.js:198:13) Jan 15 18:50:05 OpenHAB Node-RED[26298]: at TLSSocket. (/home/pi/.node-red/node_modules/castv2/lib/client.js:40:10) Jan 15 18:50:05 OpenHAB Node-RED[26298]: at Object.onceWrapper (events.js:286:20) Jan 15 18:50:05 OpenHAB Node-RED[26298]: at TLSSocket.emit (events.js:198:13) Jan 15 18:50:05 OpenHAB Node-RED[26298]: at TLSSocket.onConnectSecure (_tls_wrap.js:1079:12) Jan 15 18:50:05 OpenHAB Node-RED[26298]: at TLSSocket.emit (events.js:198:13) Jan 15 18:50:05 OpenHAB Node-RED[26298]: at TLSSocket._finishInit (_tls_wrap.js:636:8) Jan 15 18:50:05 OpenHAB rsyslogd-2007: action 'action 18' suspended, next retry is Wed Jan 15 18:50:35 2020 [try http://www.rsyslog.com/e/2007 ] Jan 15 18:50:05 OpenHAB systemd[1]: nodered.service: main process exited, code=exited, status=1/FAILURE Jan 15 18:50:05 OpenHAB systemd[1]: Unit nodered.service entered failed state. Jan 15 18:50:05 OpenHAB systemd[1]: nodered.service holdoff time over, scheduling restart. Jan 15 18:50:05 OpenHAB systemd[1]: Stopping Node-RED graphical event wiring tool... Jan 15 18:50:05 OpenHAB systemd[1]: Starting Node-RED graphical event wiring tool... Jan 15 18:50:05 OpenHAB systemd[1]: Started Node-RED graphical event wiring tool.

The logs looks the same from a few days ago when I was node-red restarted as well. I am running castv2 version 1.1.4 I am just upgrading to 1.1.7. Node Red version is 1.0.2.

i8beef commented 4 years ago

I have been working too long in sane languages expecting that try/catch to actually, ya know, catch the errors....

Publishing with a new version with an ugly nuclear option fix for this. Ill have some others review and probably push a better version of this later once they tell me how bad I suck at node.js 😄

i8beef commented 4 years ago

I just pushed 2.0 which I completely reworked to use promises around the library that gives castv2 support so that the error handling isn't abysmal. Try this out and let me know if it fixes your issue. It seemed to work better for me after I was able to eventually duplicate your issue.