node-red-contrib-home-assistant-websocket icon indicating copy to clipboard operation
node-red-contrib-home-assistant-websocket copied to clipboard

Node RED crashes when HA restarted

Open JasonBSteele opened this issue 1 year ago • 4 comments

Describe the bug

I have NR and HA running in separate containers on a Synology NAS.

When I restart HA so that updated integrations are used, NR also restarts.

To Reproduce

  1. Restart HA
  2. Check whether NR has restarted
  3. Check the NR log for errors

Expected behavior

I wouldn't expect NR to be restarted. I would hope that it would periodically retry to connect.

Screenshots

No response

Example Flow

No response

Environment Information

Version: 0.62.2

Home Assistant version: 2024.1.1 Companion version: 0.0.0 (v3.1.2, 0.0.0 was returned by the diagnostic button in NR)

Node-RED version: 3.1.3 Docker: yes Add-on: no

Node.js version: v16.20.2 x64 linux OS: Linux 4.4.302+ x64

Additional context

The error in the NR log is:

2024/01/07 12:25:59,stdout,===================
2024/01/07 12:25:59,stdout,Welcome to Node-RED
2024/01/07 12:25:59,stdout,
2024/01/07 12:25:58,stdout,7 Jan 12:25:57 - [info] 
2024/01/07 12:25:28,stdout,"7 Jan 12:25:28 - [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 \"3\".
"
2024/01/07 12:25:28,stdout,7 Jan 12:25:28 - [red] Uncaught Exception:

JasonBSteele avatar Jan 07 '24 13:01 JasonBSteele

Watching, as it is very similar to issue I logged recently.

https://github.com/zachowj/node-red-contrib-home-assistant-websocket/issues/1242

aheath70 avatar Jan 08 '24 07:01 aheath70

Can you add the code snip to the top of your NR settings.js file? So I can better understand exactly where this error is being thrown from?

process.on('unhandledRejection', (reason, p) => {
  console.log('Unhandled Rejection: ', p, 'reason:', reason);
});

zachowj avatar Jan 09 '24 02:01 zachowj

Can you add the code snip to the top of your NR settings.js file? So I can better understand exactly where this error is being thrown from?

process.on('unhandledRejection', (reason, p) => {
  console.log('Unhandled Rejection: ', p, 'reason:', reason);
});

Hi, should this be right at the top - or after module.exports?

JasonBSteele avatar Jan 10 '24 13:01 JasonBSteele

Hi, I went with putting it before module.exports. It seemed to prevent me being able to view the logs in the Container Manager as it kept getting a timeout.

When I removed the added lines and restarted, I was able to view the logs again and could see that this time I didn't get the issue with NR crashing - I could see that it repeatedly tried Connecting to HA, and then when HA came back it reconnected fine.

When I removed the extra lines from settings.js and tried again I got the error as originally reported and NR crashed.

I tried putting the lines back again. This time I was able to view the log but it wasn't updating it had stopped just before the log entry that is usually given of [info] Settings file : /data/settings.js

JasonBSteele avatar Jan 10 '24 14:01 JasonBSteele

This issue has been automatically marked as abandoned because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Mar 11 '24 06:03 github-actions[bot]