-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Websocket gets stuck and doesn't resume #10174
Comments
There's not enough relevant information here. What do you mean your function call isn't resumed? |
I'll try to give more context: Let's say my bot is in 5 guilds, and it's checking for some members/roles, here's some pseudo-code:
So my code will keep running this (while true), and I correctly see the logs, with sometimes some heartbeats in between (which is normal):
Then sometimes, the shard gets disconnected, which I guess is fine, could be some network issues, then I see this:
So it resumes the calls after reconnecting the shard. The issue is that sometimes, it somehow gets stuck and I only see the heartbeats:
|
Just happened again:
My pod doesn't "crash" so it's hard to detect and restart it because it stays in this "zombie" mode, seems to be connected but doesn't run my function. |
Pseudocode is a little hard to call a minimum reproducible sample. I assume If I had to make a guess based on the logs you've provided, Discord is kicking your shard off and telling it to resume it's session in the middle of waiting for these chunks - so they probably don't all return. It might hang waiting for the rest of those chunks. On that though - I don't understand why you're doing this every 30 seconds - at least the fetching part. Once populated, |
Correct, here's the relevant part of my code:
I'm running it with a 30s pause because I make a lot of calls and don't want to spam too much (this is run by multiple pods on thousands of guilds) |
Based on your comments about the guild member chunk, if this resolves to false for some reason
|
I think you've missed my point though - there is no reason to re-fetch entire guilds of members every 30 seconds. None at all. After populating the guild member caches once and once only, events received by subscribing to the You're welcome to run the rest of your functionality every 30 seconds, I'm not commenting on that. |
I understand I'll optimize the code to pull from cache instead of refetching everytime (I guess using membercount === member.length), but I think there's still some underlying issue with the websocket getting stuck in that heartbeat only mode. |
Provide a reproducible sample that causes that to happen without your spam of unnecessary member fetches and we‘ll happily take a look. |
I identified the issue, it was from my own code logic (slow queries clogging the process). Closing the ticket, thanks for help! |
Which package is this bug report for?
discord.js
Issue description
I have a function that runs continuously in a loop that checks for server members and roles.
Sometimes the shard is being destroyed but I can see in the logs it gets resumed, and the events are being replayed (function resumes as if nothing happened):
But some other times, my function call doesn't get resumed and all I see in the logs are the heartbeats until I kill the process and restart it manually:
I'm not using any kind of custom retry mechanism (all handled by discordjs), open to any idea on why that could happen or what I can do/add to give better details, thanks.
Code sample
No response
Versions
Issue priority
Medium (should be fixed soon)
Which partials do you have configured?
Not applicable
Which gateway intents are you subscribing to?
GuildMembers
I have tested this issue on a development release
No response
The text was updated successfully, but these errors were encountered: