MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 scanStop listeners added. Use emitter.setMaxListeners() to increase limit #22

Hi

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

Thanks

Which node are you using to do the scanning? The issue will likely be inside that node and for its author to fix.

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.

Any help would be great :slight_smile:

I wouldn’t hold your breath waiting for a response. That node looks like it has been abandoned. Last update was over 3 years ago.

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.

Where do we set this emitter.setMaxListeners() thing ?

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.

1 Like

I get these warnings too.

click me

@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 ...

this is how it looks like

Mos would say its a bad use of node-red ... but I dont care, it works for me :slight_smile:

Did you find where to set this ? I have the same trouble and I do not find where to define it... Thank you !