(node:630) MaxListenersExceededWarning: Possible EventEmitter memory leak detected

I am in need of urgent help.

(node:630) MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 message listeners added to [Client]. Use emitter.setMaxListeners() to increase limit

i tried doing

client.setMaxListeners(Infinity)

but the events are still not doing it

help pleaase

Hi @cerebalisc, welcome! :slight_smile:

What kind of project is this?

Judging from the warning message, 11 message listeners added to [Client], maybe your code is working as designed? How many listeners did you think you added? It looks like its only a warning rather than a runtime error.

Is your project having a problem, and if so what is it doing vs what you expected it to do?

it’s mainly like a level system i suppose and yes sometimes it ignores what its supposed to do and doesnt do it.

i can send the source in private message?

No thanks, I like to help publicly so that everyone can benefit from the answers.

I see you’ve noticed another thread with a suggested solution: Help me (MaxListeners) - #6 by yogurtsyum

Do you have lots of blocks like this?:

client.on(`message`, async function (msg){

});

Or is there a chance that you are repeatedly instantiating part of your bot in a loop or a lightweight function without realising it?

It might be helpful to add in something like console.trace("Listener attached") inside your client.on blocks so you can see in your logs when and why they are being called.

I doubt your source code is that sensitive unless you’ve put your discord keys in there (tip, put them in .env instead) so maybe you could share some snippets of it.

Hope this helps :slight_smile:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.