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: