Open
Conversation
There was a problem hiding this comment.
Pull Request Overview
Adds configurable socket timeout logic to detect and recover more quickly from zombie gateway connections prior to receiving the initial Discord hello, reducing long blocking periods.
- Introduces set_socket_timeout helper and applies an initial 2s timeout before handshake.
- Adjusts timeout after hello to heartbeat interval + 1 and adds rescue for IO::TimeoutError in websocket loop.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Member
|
Sorry please ignore the clanker it was a misclick on mobile |
676c866 to
3a039c9
Compare
bcf8bc9 to
684c113
Compare
Author
|
Sorry I should've run rubocop myself. |
Droid00000
reviewed
Nov 12, 2025
Author
Basically I rewrote the behavior of |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
While Discordrb has been working flawlessly on my machine, after I moved to another place, it starts seeing errors like tihs frequently:
Notice that the time between the two errors is 15min 10s (and it always is whenever this happens), which is a pretty long time for a Discord bot to be down. This timeout threshold is probably set somewhere in
/proc/sys/net/ipv4/tcp_*(and nowhere else sets a timeout, so it will otherwise just hang indefinitely), but I am not sure. Anyway, the workaround that I have come up with requires some modification to Discordrb which I have done in this PR. It should not affect any existing users, but will help in this particular case where the socket becomes zombie before the first hello message.I am not sure whether the 2s initial timeout I set here is too short or not, but I think it will not normally be exceeded even in very poor network conditions. If it is too short, I can make it to be configurable by an environment variable so that people can set this according to the network condition.
Added
Sets a timeout on the socket connected to Discord gateway.
Changed
Deprecated
Removed
Fixed