Repository navigation
Conversation
Replace stale gateway, UDP, and DAVE transports after a move, ignore callbacks from old generations, and restore speaking after the new handshake.
Discord sends these close codes both for a real disconnect and for a channel move. Closing the conn here loses the VoiceStateUpdate/VoiceServerUpdate pair that follows a move, so leave the conn alive and let those events decide.
jovolopez
force-pushed
the
fix/voice-channel-move
branch
from
November 11, 2026 02:24
2f50e6a to
e85d45f
Compare
Contributor
Author
|
Let me know if you need me to clarify anything in order to proceed with the review. |
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.
When a bot is moved from one channel to another, it often disconnects, and sometimes it simply remains silent (waiting for the DAVE session to be ready). These problems are solved with these two changes:
Rebuild voice transports when moving between channels and ignore stale callbacks
A channel move was reusing the old Gateway/UDP/DAVE generation and stale SSRC entries carried over from the old channel, so a late Ready/SessionDescription or speaking event could revive the old epoch and drop the new handshake. On moved VoiceStateUpdate the generation is now replaced via resetTransportsLocked() under stateMu and callbacks from previous gateways are dropped. SpeakingFlags are saved in SetSpeaking and restored after SessionDescription.
Wait for the fresh VoiceStateUpdate + VoiceServerUpdate pair instead of closing immediately on 4014/4022
A move can surface as a gateway close. The same thing I make in the PR #583, only without the massive fallback. I'm uploading it here because it's necessary for the complete fix to work; otherwise, the gateway ends up closing in many cases.