Unhandled promise rejection after a reconnection and during resubscribing to events
zachowj opened this issue · comments
Getting an unhandled promise rejection when it's resubscribing to events after a reconnect and the socket drops the connection.
home-assistant-js-websocket/lib/connection.ts
Lines 156 to 159 in 5d14aee
Getting two different errors seems to be a race condition on which one gets thrown.
First One:
This is referencing the above SendMessagePromise
UnhandledPromiseRejectionWarning: Error: WebSocket is not open: readyState 2 (CLOSING)
at WebSocket.send (/opt/node_modules/node-red-contrib-home-assistant-websocket/node_modules/ws/lib/websocket.js:314:19)
at e.sendMessage (/opt/node_modules/home-assistant-js-websocket/dist/haws.umd.js:1:3458)
at /opt/node_modules/home-assistant-js-websocket/dist/haws.umd.js:1:3630
at new Promise (<anonymous>)
at e.sendMessagePromise (/opt/node_modules/home-assistant-js-websocket/dist/haws.umd.js:1:3546)
at p (/opt/node_modules/home-assistant-js-websocket/dist/haws.umd.js:1:8102)
at w (/opt/node_modules/home-assistant-js-websocket/dist/haws.umd.js:1:8802)
at /opt/node_modules/home-assistant-js-websocket/dist/haws.umd.js:1:7847
at /opt/node_modules/home-assistant-js-websocket/dist/haws.umd.js:1:1440
at Object.next (/opt/node_modules/home-assistant-js-websocket/dist/haws.umd.js:1:1545)
Second One:
home-assistant-js-websocket/lib/connection.ts
Lines 244 to 250 in 5d14aee
Context:
Using node-red-contrib-home-assistant-websocket within hass.io and the addon-node-red. Everything works fine with the connection until you reboot hass.io and the addon is trying to reconnect. While trying to reconnect to Home Assistant it connects and disconnects from the hass.io proxy several times that's when the errors are getting thrown.