Hello lovely folks,
I would like to request a feature to make Node-RED a bit more robust and stable.
Currently when NR faces a network exception for whatever reason (e.g. temporary network outage, DNS lookup problems, etc.) the whole thing shuts down, because the exception bubbles up to the top, resulting in a boot-loop in my case (running NR via docker compose). The only way to fix it is to stop the container, edit the flows file by hand (disabling it altogether), restart NR, then re-enable almost everything.
In my case 2 contrib nodes cause the problem: node-red-contrib-spotify (node) - Node-RED and node-red-node-openweathermap (node) - Node-RED. Both of them do some network requests (immediately on startup, or on a schedule), which can fail, resulting in said boot-loop. Example logs of boot-loop:
[...]
25 Mar 16:23:43 - [info] Starting flows
25 Mar 16:23:44 - [info] Started flows
25 Mar 16:23:44 - [info] [zigbee2mqtt-server:5a4167ca1a055afa] MQTT Connected
25 Mar 16:23:44 - [info] [mqtt-broker:mosquitto] Connected to broker: nodered@mqtt://mosquitto:1883
25 Mar 16:23:44 - [info] [zigbee2mqtt-server:5a4167ca1a055afa] MQTT Subscribed to: "zigbee2mqtt/#"
[...]
[red] Uncaught Exception:
25 Mar 16:23:59 - [error] Error: getaddrinfo EAI_AGAIN accounts.spotify.com
at GetAddrInfoReqWrap.onlookupall [as oncomplete] (node:dns:122:26)
25 Mar 16:24:05 - [info]
Welcome to Node-RED
===================
25 Mar 16:24:05 - [info] Node-RED version: v4.1.1
25 Mar 16:24:05 - [info] Node.js version: v22.20.0
[...]
Unfortunately this happens very frequently, since my ISP tends to have outages during storms or when it heckin wimdy, so I would really appreciate if NR would catch these exceptions and deal with them somehow (periodically re-init these contrib nodes/plugins or something similar, but most importantly prevent a full crash).
The alternative solution would be to catch these exceptions on the contrib node level, but I don't think it's feasible to update all contrib packages, so it would be much more robust to handle them on the NR side.
I searched on the forum for possible solutions, didn't find anything applicable, but I see this problem affects others as well.
- Node-red crash when network is down? - General - Node-RED Forum
- Restart loop after a mistyped IP address - General - Node-RED Forum
- Help needed, Node-red crashed! - General - Node-RED Forum
- And this 4 years old contrib node bugreport, with no activity in sight: Wrong ip value causes node red to crash · Issue #8 · inwaar/node-red-contrib-gree-hvac
What do you think? I would really appreciate if we had a way to catch and handle these network exceptions and prevent NR from crashing completely.
Thanks in advance!