[Bug]: RequestQueue leak
nvmp-main opened this issue · 6 comments
Check The Docs
- I double checked the docs and couldn't find any useful information.
Verify Issue Source
- I verified the issue was caused by Discord.Net.
Check your intents
- I double checked that I have the required intents.
Description
We use Discord.Net in a game server application that runs for days at a time, and after a while our performance slowly starts to degrade. Whilst I have been investigating memory dumps of our managed environment, we are seeing lots of tasks awaiting execution or are pending execution waiting inside Discord.Net.Queue.RequestQueue.RunCleanup
. This doesn't seem right to us to have a lot of these tasks in memory waiting in this code, they even persist when we have no active clients in our server.
It may seem that looking at the implementation of RequestQueue, that it is not being correctly disposed of when used a member of RequestBucket. I am not overly familiar with this code, but it would potentially make sense to why there are so many tasks still waiting for cancellation via the disposable interface.
Version
3.10.0
Working Version
No response
Logs
Sample
No response
Packages
N/A
I have the same problem on a project. Hunderts if not thousends of Tasks are waiting and new Tasks are not being run, hanging the service.
My only guess here is that the token source responsible for exiting the RunCleanup
task is disposed before waiting for the task to complete. I'll create a branch for you to test out to see if my potential fix works.
Have a play with https://github.com/discord-net/Discord.Net/tree/fix/request-queue-leak and let me know if the problem persists
Have a play with https://github.com/discord-net/Discord.Net/tree/fix/request-queue-leak and let me know if the problem persists
Sorry for the late response. Is there any NuGet Package Version for this or do I have to build it myself?
Sorry for the late response. Is there any NuGet Package Version for this or do I have to build it myself?
You'd need to build it yourself. Clone the repo, checkout the branch & do dotnet build