Skip to content

fix(gateway): use resume_gateway_url when reconnecting#439

Open
NickIsADev wants to merge 1 commit intoSinisterRectus:masterfrom
NickIsADev:resume-fix
Open

fix(gateway): use resume_gateway_url when reconnecting#439
NickIsADev wants to merge 1 commit intoSinisterRectus:masterfrom
NickIsADev:resume-fix

Conversation

@NickIsADev
Copy link
Copy Markdown
Contributor

@NickIsADev NickIsADev commented Feb 22, 2026

This pull requests implements the missing handling of resume_gateway_url, which was added to the Gateway in August of 2022 (https://docs.discord.com/developers/change-log#session-specific-gateway-resume-urls). The system was pushed into full use later in September of the same year.

This system does not exist for the Voice Gateway at the moment, hence why no changes were made there.

Changes:

  • Store Shard._resume_gateway_url when receiving it via the READY event
  • Use Shard._resume_gateway_url to reconnect if available, otherwise use original gateway URL

Documentation Reference: https://docs.discord.com/developers/events/gateway#preparing-to-resume

@NickIsADev
Copy link
Copy Markdown
Contributor Author

NickIsADev commented Feb 22, 2026

I've also noticed that Discordia does not properly produce jitter on the initial heartbeat, however I'm unsure of how to approach this issue while keeping the code clean and readable. I've thought of just using sleep(heartbeat_interval * math.random) or setTimeout, however that could lead to even more issues with many heartbeat timers running if multiple reconnects happen quickly (for whatever reason).

Documentation Reference: https://docs.discord.com/developers/events/gateway#heartbeat-interval

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant