I have a flow in node red that after some time stops initialising the BLE scanner node. I have a delay loop activating the scanner (noble node) switching between true and false at a set interval. Everything works well initially but after a while the scan node remains on 'started' state and nothing updates. The node red console indicates "MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 scanStop listeners added. Use emitter.setMaxListeners() to increase limit noble node red."
I have read that this can be changed in the node js but don't know what file I need to change. Any help would be great
I posted this in the github but didnt get a reply. I dont know what else I can use or if I can change the authors script to increase the max listeners.
I'm slightly surprised that the node stops working, but I haven't looked at the code. The message is only a warning, not an error, but there may be something that responds to it and shuts the node down. It's less likely that you are really running out of memory, because the symptoms would be worse.
The immediate problem could be fixed by doing as the message says:
(The default limit is 10 listeners, which is why the node complains when the count reaches 11.)
If the warning persists for large values of setMaxListeners, the node may not be doing its housekeeping properly and leaking memory as a result.
It has to be set in the node that is emitting the event, which means editing the source of the node that is producing them. But as noted it's normally just a warning.
@WhiteLion this is a generic warning, so by itself, it doesn't give us enough information to help. In your flows, have you got more than ten instances of any particular contrib node?
I think I do have. I realy rape node-red: my (light) switch flow (I ve 12 of them) has 166 nodes .... about 20 dashbord about 80 function nodes with 3 - 40 lines of code each.... some is debug, delay, subflow ...
Sorry to resurrect this thread, but I found that one of my nodes suffers from the same culprit. If I know which node causes it, that would really help me forward. This is the output from my log:
(node:17) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 connecting listeners added. Use emitter.setMaxListeners() to increase limit
(node:17) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 connect listeners added. Use emitter.setMaxListeners() to increase limit
(node:17) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 close listeners added. Use emitter.setMaxListeners() to increase limit
Well. one way would be to disable parts of your flow to narrow down the suspect. You could also add a catch node connected to a dbug node (set to display the 'complete msg object') and see if it gives any more information.
Disabling parts of my flow looks like a lot of work, given the many number of tabs involved. I think it's especially hard because there seems no consistent way to reproduce the warning messages in my case, so maybe it's not a big problem after all?
Anyhow, I'm using lots of modules, so posting the list here might help cross-reference it with others to narrow down a (or more) possible suspects:
Hello,
I'm reviving this topic to get a better understanding of this Error if it is an error.
(node:2072002) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 opened listeners added to [WebSocketListenerNode]. Use emitter.setMaxListeners() to increase limit
0|Demo_iLab |
(node:2072002) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 erro listeners added to [WebSocketListenerNode]. Use emitter.setMaxListeners() to increase limit
0|Demo_iLab |
(node:2072002) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 closed listeners added to [WebSocketListenerNode]. Use emitter.setMaxListeners() to increase limit
My understanding :
I have a WebSocket "Input Node" that forward messages along the pipes
I have a SubFlow "Send Message" that wrap a WebSocket "Output Node" to reply custom messages
I use 100 instances of this subflow to send messages back to the user. (I have a session mechanics that retrieve the socket context and reply)
This mechanics is really clean and works well for years along Node-Red various version. But I always get this error in the logs and I wondering if I should increase this max limit ?
The Arrows targets a parent's parent's flow that use my websocket subflow.
What happenend If I use that cool Subflow Node in many flows and suflows ? Is it reused or duplicated ? I assume it is duplicated and that would explain this warning ?
Is it a problem ? May be for many concurent messages ?
Every node in a subflow is a unique instantiated node.
If you have 10 nodes in a subflow and you have 100 instances of that subflow, you have 1000 nodes. If you use "full deploy" mode, then 1000 nodes get destroyed and re-created (and all of the internal connections they create etc etc). It is common to see slowdowns when working with large numbers of subflows.
If you have subflows in subflows, then this count starts getting to crazy numbers.
Often, there is no need for a subflow. for example, using the link-call node can be a better fit and will not have the same issue.
PS: I rarely use subflows. I often use link-call to create subroutines instead.
@Steve-Mcl is not referring to link nodes, but to link-call nodes, which is a different concept that makes reusable flows possible, without cluttering the UI as it will exist as a single node within the flow.