Hi
Recently I've detected some random problems when trying to connect to mongo using the node-red-contrib-mongodb4 plugin. Attached you have a simple flow that includes some basic stuff to get the collections from a database, try to find a specific one (defined in the init node) and do something depending on whether it exists or not. If it does, show its contents and if it doesn't, try to create it.
In the past I detected a problem that seemed to be related with the auto-cloning of messages at the output of a node in case this output goes to multiple nodes (out of memory or something like that, don't remember the exact error, but I'd same a deep clone of the response of a collections request was too much for some reason). As a result, as you can see in Example 3, if only one node consumes the output (in my case it's a function node), everything works fine, as long as I create a new message for the output of the function to prevent here again the deep clone.
However, if I test this in Example 1, you can see the output of Get collections 1 connected to a debug and a function node and works fine Magic?
So, after going back to the initial "solution" (no debug node, just let the message go to the function node), I decided to add a Complete node to see whether the problem appeared when trying to get the collections, when trying to get the elements of the selected collection or when trying to create it.
Results:
- With the Complete node enabled, I see a "RangeError: Maximum call stack size exceeded" message generated by Get collections 1, but it still works fine. Or at least it works fine in this flow, because in my main flow (exact same set of nodes for this part), the execution sometimes get frozen there and I need to restart nodered..
- In my main flow, if the flow can continue after Get collections 1, since the target collection doesn't exist, it gets frozen in Create collection 1.
I mean.. what is this? The database is working fine (it works like a charm in this example flow which does the exact same things), there's no connectivity problem (otherwise it'd never work)..
Just in case it's relevant, I'm using node-red 4.0.2 on top of node.js 20.16.0 and mongo 4.2.
Regards
flows.json (21.1 KB)