discord.js-modules
discord.js-modules copied to clipboard
(@discordjs/rest) Hashes can cause memory leak
Please describe the problem you are having in as much detail as possible:
As I noticed in: https://github.com/discordjs/discord.js-next/blob/6ebe80f1d3f72c6d66e515620c590d4cd6398a15/packages/rest/src/lib/RequestManager.ts#L119 and https://github.com/discordjs/discord.js-next/blob/6ebe80f1d3f72c6d66e515620c590d4cd6398a15/packages/rest/src/lib/handlers/SequentialHandler.ts#L167
Hashes will the be empty at first and will just pile up as the bot runs, and replace the existing hash when the hash is updated, but this doesn't account deletes, ex: guild delete, channel delete, etc. means those hashes from those deleted guild, channels, etc will remain in memory. Since there are no sweeper, or a lru cache that can remove the unused hashes after x amount of time, this existing hashes that is from a deleted guild or channel will pile up causing a memory leak, which can eventually crash a bot