Memory leak in discord js
I am currently facing a problem with a memory leak. I don't quite think it's related to discord.js, nevertheless I would like to ask if there are any common mistakes you can make with discord.js that lead to a memory leak. Or are there any other known problems with discord.js that lead to memory leaks?
10 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!nesting event listeners, enabling unnecessary intents, making multiple event listeners for the same event
i just had a similar ish issue and it seems sweepers/ cache settings helped
.-. I'm having the same problem with v14.14.x
currently trying to trace it down, but using 637e1a4ddb6d5810deb31c5b90400ca277218270 is fine, 2d63d935581a953118e7cff9cb1ab6347f4ba3c3 is not (after the v14.14.x release)
^, they won't help fixing this... xD
and the problem is in either
discord.js
, @discordjs/util
or @discordjs/rest
because I only pull those from GitHub
don't have much more info other than it happening randomly after a few hours after the bot started 🤷
And the amount the memory increases by is random, sometimes it's at the limit within a hour, sometimes it takes three hours to reach it
Well and it doesn't seem to affect smaller bots with less members/intents to cache I suppose? At least my other bots haven't seen a real change in memory usage
I'll give it a full read later, tho I've already tried created a heap dump before a memory leak started and the process crashed while creating it due to reaching the memory limit
I haven't tried things like --inspect
yet, tho I generally want to avoid them because I can easily mess up something, causing the process to abort which would be bad
Changes in the process management code require a full restart of the whole server which is something I don't want to do often
As long as I don't have to use the latest djs version, I'll just try finding the commit which started breaking it
Nope, that guide doesn't help me at all because the issue is not in my code xD
I was able to create a heap dump now using the heapdump
package, I'll try creating another one once memory starts leaking againHey @Qjuh, ive been having similar issues and saw the link you sent has AppSignal. Have you ever used it? I'm struggling to install it myself and would like some help if you have any knowledge with that
Because it worked before I've updated djs, then it started leaking, and after I've changed back to 637e1a4ddb6d5810deb31c5b90400ca277218270 it stopped leaking
What even is that long string?
ahh
Looks like
95c0b1a59f3dc8f496a966e9f3e947b0cd9e81b8
doesn't leak too, testing with aad82f088b4d39f7996980f8f71bfc6e5dee5c52
now
As Qjuh said it's a Git hash, which I use for referencing a specific version of the code. Though I've made my own script to load the packages from GitHub, because while you can install a npm package from a hash, you can't run any build scripts or similar with it, however they are required by djs to work
Because the dev releases are just "the" dev release, there's no version attached to it which makes things like debugging which commit (might) have caused it much harder
oh, well nevermind then
I only saw discord.js@dev
some time ago and thought that's it