zachowj / node-red-contrib-home-assistant-websocket

Node-RED integration with Home Assistant
https://zachowj.github.io/node-red-contrib-home-assistant-websocket/
MIT License
484 stars 88 forks source link

UnhandledPromiseRejection after upgrade from 0.49.1 to 0.55.1 - crash NR #1030

Closed marc-gist closed 1 year ago

marc-gist commented 1 year ago

Describe the bug

After upgrading NodeRed crashes last message in log is

8 Aug 07:51:48 - [info] [server:HA-Arena] Connected to https://xxx
8 Aug 07:51:48 - [info] [server:HA-Test] Connected to https://xxx
8 Aug 07:51:48 - [info] [server:HAHouse] Connected to https://xxx
8 Aug 07:51:49 - [red] Uncaught Exception:
8 Aug 07:51:49 - [error] UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<Object>".

To Reproduce

Upgrade from 0.49.1 to 0.55.1 Have 3 connections to different HA servers

Expected behavior

To work as usual

Screenshots

No response

Example Flow

No response

This package's version (not the Home Assistant add-on version)

0.55.1

Is Node-RED running in Docker?

Yes

Node-RED version

3.0.2

Node.js version

16.16.0

Additional context

No response

msmarks commented 1 year ago

The log is

8 Aug 23:19:19 - [info]

Welcome to Node-RED
===================

8 Aug 23:19:19 - [info] Node-RED version: v3.0.2
8 Aug 23:19:19 - [info] Node.js  version: v18.17.0
8 Aug 23:19:19 - [info] Linux 5.10.0-21-amd64 x64 LE
8 Aug 23:19:20 - [info] Loading palette nodes
8 Aug 23:19:24 - [info] Dashboard version 3.5.0 started at /endpoint/ui
8 Aug 23:19:25 - [info] Settings file  : /opt/config.js
8 Aug 23:19:25 - [info] Context store  : 'default' [module=memory]
8 Aug 23:19:25 - [info] User directory : /config/node-red/
8 Aug 23:19:25 - [warn] Projects disabled : editorTheme.projects.enabled=false
8 Aug 23:19:25 - [info] Flows file     : /config/node-red/flows.json
8 Aug 23:19:25 - [info] Server now running at http://127.0.0.1:46836/
8 Aug 23:19:25 - [info] Starting flows
8 Aug 23:19:25 - [info] Started flows
8 Aug 23:19:25 - [info] [server:Home Assistant Remote] Connecting to http://192.168.11.6:8123
8 Aug 23:19:25 - [info] [server:Home Assistant Remote] Connected to http://192.168.11.6:8123
8 Aug 23:19:25 - [red] Uncaught Exception:
8 Aug 23:19:25 - [error] UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "#<Object>".

The UnhandledPromiseRejection is

Unhandled Rejection at: Promise {
  <rejected> { code: 'unknown_command', message: 'Unknown command.' }
}

stack trace is

[ Stacktrace altered by https://github.com/grantila/trace-unhandled ]
Unknown command.
    ==== Promise at: ==================
    at TraceablePromise.then (<anonymous>)
    at TraceablePromise.catch (<anonymous>)
    at refreshSwallow (/opt/node_modules/home-assistant-js-websocket/dist/haws.cjs:815:49)
    at setupUpdateSubscription (/opt/node_modules/home-assistant-js-websocket/dist/haws.cjs:834:13)
    at Object.subscribe (/opt/node_modules/home-assistant-js-websocket/dist/haws.cjs:868:17)
    at subscribeEntityRegistryDisplay (/opt/node_modules/node-red-contrib-home-assistant-websocket/dist/homeAssistant/collections.js:39:16)
    at Websocket._Websocket_haEvents (/opt/node_modules/node-red-contrib-home-assistant-websocket/dist/homeAssistant/Websocket.js:426:54)
zachowj commented 1 year ago

Are you running a version of Home Assistant before 2023.3.0?

marc-gist commented 1 year ago

Are you running a version of Home Assistant before 2023.3.0?

I happen to be (one is 2022.7.2). not sure about @msmarks

It should still "fail gracefully" and not completely take out NodeRed :(