Since a week I facing a strange crash on one of my nodered container (running in AWS ECS on a FARGATE instance)
There is no memory or CPU overload but something seems to happen that I have not been able to identify
Nodered version is 3.0.2, default docker imagebased on node 16.20.2
You would says that as it happens everyday at the same hour it should be easy to identify the guilty flow but actually I don't have any flow that start at that time, so I'm a bit clue less
Here is what I see in the logs prior to the crash:
2 Apr 09:17:11 - [red] Uncaught Exception:
at processImmediate (node:internal/timers:466:21)
at Immediate.<anonymous> (/usr/src/node-red/node_modules/@node-red/runtime/lib/flows/Flow.js:831:52)
2 Apr 09:17:11 - [error] TypeError: sendEvent.destination.node.receive is not a function
'===================
Welcome to Node-RED
2 Apr 09:18:06 - [info]
I also noticed that just after restart there are those errors that I can't neither link to something:
2 Apr 09:18:49 - [warn]
2 Apr 09:18:49 - [info] Starting flows
TypeError: Cannot read properties of undefined (reading 'id')
at Object.start [as startFlows] (/usr/src/node-red/node_modules/@node-red/runtime/lib/flows/index.js:394:33)
at Flow.start (/usr/src/node-red/node_modules/@node-red/runtime/lib/flows/Flow.js:224:41)
at Subflow.start (/usr/src/node-red/node_modules/@node-red/runtime/lib/flows/Subflow.js:209:62)
at Array.map (<anonymous>)
at /usr/src/node-red/node_modules/@node-red/runtime/lib/flows/Subflow.js:209:95
at Array.map (<anonymous>)
at /usr/src/node-red/node_modules/@node-red/runtime/lib/flows/Subflow.js:209:140
2 Apr 09:19:23 - [info] [mongodb-aleph-in:find in custom_metadata] connecting to mongodb...
at Object.start [as startFlows] (/usr/src/node-red/node_modules/@node-red/runtime/lib/flows/index.js:394:33)
at Flow.start (/usr/src/node-red/node_modules/@node-red/runtime/lib/flows/Flow.js:224:41)
at Subflow.start (/usr/src/node-red/node_modules/@node-red/runtime/lib/flows/Subflow.js:209:62)
at Array.map (<anonymous>)
at /usr/src/node-red/node_modules/@node-red/runtime/lib/flows/Subflow.js:209:95
at Array.map (<anonymous>)
at /usr/src/node-red/node_modules/@node-red/runtime/lib/flows/Subflow.js:209:140
TypeError: Cannot read properties of undefined (reading 'id')
2 Apr 09:19:23 - [info] Started flows
(Use `node --trace-warnings ...` to show where the warning was created)
Any advice to help tracking down where this could happen would be appreciated
Thanks
The Trace setting is more about determining what is causing the errors on startup. Though it may give information about the crash too, but less likely.
Which seems to locate the problem in subflow e7ee7117246f4ae3
The problem seems to occur in that line (node-red3.0.2):
One of the 2 .id seems to be non existant
Any idea what could cause that ?
We have other node-red instances running in similar conditions (other AWS regions) with same nodes and subflows and I haven't cound the same log in the last 30 days.
Not really necessary unless you are relying on the complete node.
If node.done() is excluded, it will still (implicitly) trigger a complete node - however it will be triggered regardless of success (i.e. even node.error is called / node.send not called) when the function node ends cleanly. By adding the explicit node.done, you control when the complete node is triggered.
In short, node.send will send regardless of the inclusion or exclusion of node.done
I stopped that flow.
I believe that code is not the best, and may be those 2 x node.done() is bad and more likely responsible for the sendEvent.destination.node.receive is not a function error message.
I believe it should be enough to write it like:
Why do you even need to send 2 messages? The data you want is already present in the msg. Where are you sending these 2 messages that you generate in the function?
as for "better"? No, what you are doing is better suited to a change nodes and wires (that is after all the point of visual programming)
the wires branching here ^ will cause the msg to be duplicated, then the change nodes will set your payloads - but i re-iterate, since your values are already in one node, why not just use them?