Node red crashes

Hi!

every time node red crashes when doing nothing
have no idea what or where
i found this below in the log

Nov  5 15:11:49 bomb-game Node-RED[16879]: (node:16879) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or$
Nov  5 15:11:49 bomb-game Node-RED[16879]: (node:16879) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js $
Nov  5 15:11:49 bomb-game Node-RED[16879]: (node:16879) UnhandledPromiseRejectionWarning: Error: Huejay: timeout of 15000ms exceeded
Nov  5 15:11:49 bomb-game Node-RED[16879]:     at /home/pi/.node-red/node_modules/huejay/lib/Transport.js:106:15
Nov  5 15:11:49 bomb-game Node-RED[16879]:     at processTicksAndRejections (internal/process/task_queues.js:95:5)
Nov  5 15:11:49 bomb-game Node-RED[16879]:     at runNextTicks (internal/process/task_queues.js:64:3)
Nov  5 15:11:49 bomb-game Node-RED[16879]:     at listOnTimeout (internal/timers.js:526:9)
Nov  5 15:11:49 bomb-game Node-RED[16879]:     at processTimers (internal/timers.js:500:7)
Nov  5 15:11:49 bomb-game Node-RED[16879]: (node:16879) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or$
Nov  5 15:11:49 bomb-game Node-RED[16879]: (node:16879) UnhandledPromiseRejectionWarning: Error: Huejay: timeout of 15000ms exceeded
Nov  5 15:11:49 bomb-game Node-RED[16879]:     at /home/pi/.node-red/node_modules/huejay/lib/Transport.js:106:15
Nov  5 15:11:49 bomb-game Node-RED[16879]:     at processTicksAndRejections (internal/process/task_queues.js:95:5)
Nov  5 15:11:49 bomb-game Node-RED[16879]:     at runNextTicks (internal/process/task_queues.js:64:3)
Nov  5 15:11:49 bomb-game Node-RED[16879]:     at listOnTimeout (internal/timers.js:526:9)
Nov  5 15:11:49 bomb-game Node-RED[16879]:     at processTimers (internal/timers.js:500:7)
Nov  5 15:11:49 bomb-game Node-RED[16879]: (node:16879) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or$
Nov  5 15:14:36 bomb-game Node-RED[16879]: <--- Last few GCs --->
Nov  5 15:14:36 bomb-game Node-RED[16879]: [16879:0x3cb6bd8]  2690949 ms: Scavenge 2043.4 (2049.3) -> 2041.9 (2049.3) MB, 4.9 / 0.0 ms  (average mu = 0.319, current mu = 0.294) task
Nov  5 15:14:36 bomb-game Node-RED[16879]: [16879:0x3cb6bd8]  2691031 ms: Scavenge 2043.5 (2049.3) -> 2042.0 (2049.3) MB, 4.8 / 0.0 ms  (average mu = 0.319, current mu = 0.294) task
Nov  5 15:14:36 bomb-game Node-RED[16879]: [16879:0x3cb6bd8]  2691112 ms: Scavenge 2043.6 (2053.3) -> 2042.1 (2053.3) MB, 5.5 / 0.0 ms  (average mu = 0.319, current mu = 0.294) task
Nov  5 15:14:36 bomb-game Node-RED[16879]: <--- JS stacktrace --->
Nov  5 15:14:36 bomb-game Node-RED[16879]: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
Nov  5 15:14:36 bomb-game systemd[1]: nodered.service: Main process exited, code=killed, status=6/ABRT
Nov  5 15:14:36 bomb-game systemd[1]: nodered.service: Failed with result 'signal'.
Nov  5 15:14:56 bomb-game systemd[1]: nodered.service: Service RestartSec=20s expired, scheduling restart.
Nov  5 15:14:56 bomb-game systemd[1]: nodered.service: Scheduled restart job, restart counter is at 6.
Nov  5 15:14:56 bomb-game systemd[1]: Stopped Node-RED graphical event wiring tool.
Nov  5 15:14:56 bomb-game systemd[1]: Started Node-RED graphical event wiring tool.
Nov  5 15:14:58 bomb-game Node-RED[20122]: 5 Nov 15:14:58 - [info]
Nov  5 15:14:58 bomb-game Node-RED[20122]: Welcome to Node-RED
Nov  5 15:14:58 bomb-game Node-RED[20122]: ===================
Nov  5 15:14:58 bomb-game Node-RED[20122]: 5 Nov 15:14:58 - [info] Node-RED version: v2.1.1
Nov  5 15:14:58 bomb-game Node-RED[20122]: 5 Nov 15:14:58 - [info] Node.js  version: v14.18.1
Nov  5 15:14:58 bomb-game Node-RED[20122]: 5 Nov 15:14:58 - [info] Linux 5.10.17-v7l+ arm LE
Nov  5 15:14:58 bomb-game Node-RED[20122]: 5 Nov 15:14:58 - [info] Loading palette nodes
Nov  5 15:15:00 bomb-game Node-RED[20122]: 5 Nov 15:15:00 - [info] Dashboard version 3.0.4 started at /ui
Nov  5 15:15:00 bomb-game Node-RED[20122]: 5 Nov 15:15:00 - [info] Settings file  : /home/pi/.node-red/settings.js
Nov  5 15:15:00 bomb-game Node-RED[20122]: 5 Nov 15:15:00 - [info] Context store  : 'default' [module=memory]
Nov  5 15:15:00 bomb-game Node-RED[20122]: 5 Nov 15:15:00 - [info] User directory : /home/pi/.node-red
Nov  5 15:15:00 bomb-game Node-RED[20122]: 5 Nov 15:15:00 - [warn] Projects disabled : editorTheme.projects.enabled=false
Nov  5 15:15:00 bomb-game Node-RED[20122]: 5 Nov 15:15:00 - [info] Flows file     : /home/pi/.node-red/flows.json
Nov  5 15:15:00 bomb-game Node-RED[20122]: 5 Nov 15:15:00 - [info] Server now running at http://127.0.0.1:1880/
Nov  5 15:15:00 bomb-game Node-RED[20122]: 5 Nov 15:15:00 - [warn]
Nov  5 15:15:00 bomb-game Node-RED[20122]: ---------------------------------------------------------------------

i guess it is about this line but no clue what it means

 FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

i called mark but he also dont know :wink: :wink:

The npm package huejay is crashing. Go into your .node-red folder and run
npm list huejay
which should tell you which node red node is using that, if you don't know already.

Make sure all your nodes are at the latest versions (you can check that in Manage Palette).

Thanks @Colin

npm list huejay gives me the result below, no idea what to do with that info
all nodes are up to date

node-red-project@0.0.1 /home/pi/.node-red
└─┬ node-red-contrib-huemagic@3.0.0
  └── huejay@1.9.0 

It seems solved after deleting the hue switches. But not sure about that jet

That means there is a bug in that node that crashes node-red. Unfortunately I think that node is no longer supported as there are many unaddressed issues on its github page, including other reports of crashing node-red.

o really? i loved huemagic, use it a lot....
Thanks for explanation

UPDATE

Sorry @Colin Node Red still crashes also after deleting hue-magic

the error is below

Nov  6 11:17:01 bomb-game CRON[13528]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Nov  6 11:24:01 bomb-game rngd[361]: stats: bits received from HRNG source: 140064
Nov  6 11:24:01 bomb-game rngd[361]: stats: bits sent to kernel pool: 93824
Nov  6 11:24:01 bomb-game rngd[361]: stats: entropy added to kernel pool: 93824
Nov  6 11:24:01 bomb-game rngd[361]: stats: FIPS 140-2 successes: 7
Nov  6 11:24:01 bomb-game rngd[361]: stats: FIPS 140-2 failures: 0
Nov  6 11:24:01 bomb-game rngd[361]: stats: FIPS 140-2(2001-10-10) Monobit: 0
Nov  6 11:24:01 bomb-game rngd[361]: stats: FIPS 140-2(2001-10-10) Poker: 0
Nov  6 11:24:01 bomb-game rngd[361]: stats: FIPS 140-2(2001-10-10) Runs: 0
Nov  6 11:24:01 bomb-game rngd[361]: stats: FIPS 140-2(2001-10-10) Long run: 0
Nov  6 11:24:01 bomb-game rngd[361]: stats: FIPS 140-2(2001-10-10) Continuous run: 0
Nov  6 11:24:01 bomb-game rngd[361]: stats: HRNG source speed: (min=166.238; avg=331.951; max=510.688)Kibits/s
Nov  6 11:24:01 bomb-game rngd[361]: stats: FIPS tests speed: (min=8.930; avg=16.731; max=31.268)Mibits/s
Nov  6 11:24:01 bomb-game rngd[361]: stats: Lowest ready-buffers level: 2
Nov  6 11:24:01 bomb-game rngd[361]: stats: Entropy starvations: 0
Nov  6 11:24:01 bomb-game rngd[361]: stats: Time spent starving for entropy: (min=0; avg=0.000; max=0)us
Nov  6 11:28:56 bomb-game Node-RED[10846]: <--- Last few GCs --->
Nov  6 11:28:56 bomb-game Node-RED[10846]: [10846:0x3e44bd8]  2759787 ms: Scavenge 2044.4 (2049.9) -> 2042.9 (2049.9) MB, 4.8 / 0.0 ms  (average mu = 0.307, current mu = 0.301) task
Nov  6 11:28:56 bomb-game Node-RED[10846]: [10846:0x3e44bd8]  2759879 ms: Scavenge 2044.5 (2049.9) -> 2043.0 (2049.9) MB, 4.8 / 0.0 ms  (average mu = 0.307, current mu = 0.301) task
Nov  6 11:28:56 bomb-game Node-RED[10846]: [10846:0x3e44bd8]  2759970 ms: Scavenge 2044.6 (2053.9) -> 2043.1 (2053.9) MB, 5.4 / 0.0 ms  (average mu = 0.307, current mu = 0.301) task
Nov  6 11:28:56 bomb-game Node-RED[10846]: <--- JS stacktrace --->
Nov  6 11:28:56 bomb-game Node-RED[10846]: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
Nov  6 11:28:57 bomb-game systemd[1]: nodered.service: Main process exited, code=killed, status=6/ABRT
Nov  6 11:28:57 bomb-game systemd[1]: nodered.service: Failed with result 'signal'.
Nov  6 11:29:17 bomb-game systemd[1]: nodered.service: Service RestartSec=20s expired, scheduling restart.
Nov  6 11:29:17 bomb-game systemd[1]: nodered.service: Scheduled restart job, restart counter is at 4.
Nov  6 11:29:17 bomb-game systemd[1]: Stopped Node-RED graphical event wiring tool.
Nov  6 11:29:17 bomb-game systemd[1]: Started Node-RED graphical event wiring tool.

You have run out of memory, something you are doing is using memory and not releasing it. Are you doing something with images or video or large files or something similar?

No, it is very basic what it is at the moment.
I also created a clean install and imported the node red json
Again it crashes.
There are a lot ping nodes in it, i disabled them and still same problem.

latest crash report below

6 Nov 17:17:41 - [info] [function:flows_*.json] Backup made
<--- Last few GCs --->
[5366:0x4074bd8]  2287594 ms: Scavenge (reduce) 2040.9 (2044.4) -> 2040.2 (2045.4) MB, 6.6 / 0.0 ms  (average mu = 0.181, current mu = 0.145) task
[5366:0x4074bd8]  2287652 ms: Scavenge (reduce) 2041.0 (2044.4) -> 2040.2 (2045.4) MB, 6.6 / 0.0 ms  (average mu = 0.181, current mu = 0.145) task
[5366:0x4074bd8]  2287711 ms: Scavenge (reduce) 2041.0 (2044.4) -> 2040.2 (2045.4) MB, 6.5 / 0.0 ms  (average mu = 0.181, current mu = 0.145) task
<--- JS stacktrace --->
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
nodered.service: Main process exited, code=killed, status=6/ABRT
nodered.service: Failed with result 'signal'.
nodered.service: Service RestartSec=20s expired, scheduling restart.
nodered.service: Scheduled restart job, restart counter is at 2.
Stopped Node-RED graphical event wiring tool.
Started Node-RED graphical event wiring tool.
6 Nov 17:54:43 - [info]
Welcome to Node-RED
===================
6 Nov 17:54:43 - [info] Node-RED version: v2.1.3
6 Nov 17:54:43 - [info] Node.js  version: v14.18.1
6 Nov 17:54:43 - [info] Linux 5.10.17-v7l+ arm LE

I can send you the json if you like to see what is giving the problem

Show us a screenshot of your flows please







Wow that is a lot of MQTT nodes, each one making a connection to the broker. Is the broker running on the same Pi?

What model Pi is it and how much memory does it have?

  1. For the mqtt-in bomb/result/bombN, the JSON nodes after it could be removed if in the mqtt-in node you set the Output option to a parsed JSON object.

  2. if you change the mqtt-in to use the topic bomb/result/# you could have one mqtt-in node (for that batch of nodes)followed by a switch node to test the 'topic' and send the msg to the correct function node.

  3. for the mqtt-out nodes, I would consolidate them too by having one mqtt-out node with no topic and have the incoming msg contain a msg.topic. To keep the flows neat, you could use a link node (or the new link call node) on the pages to the mqtt-out nodes

I think reducing the number of MQTT nodes will go quite aways to reducing your memory usage.

Thanks @zenofmud for taking time to scan my work.
And thanks for you feedback, i learned some new nodes today :wink:
After some playing around the problem was solved before using your tips.
No idea what it exactly was.

O and it is an pi4 with 4gb

The important thing with MQTT nodes is to only have one config node for each server. So if you click on the Server drop-down it should only show one entry (or one for each broker if you connect to multiple brokers). Then you will only have one connection to the broker and it doesn't matter how many MQTT In/Out nodes you use.