Skip to content

improve gateway stability against new discord error conditions - #2455

Open
akiraveliara wants to merge 4 commits into
masterfrom
aki/fix-shards-dying-on-invalid-hello
Open

improve gateway stability against new discord error conditions#2455
akiraveliara wants to merge 4 commits into
masterfrom
aki/fix-shards-dying-on-invalid-hello

Conversation

@akiraveliara

@akiraveliara akiraveliara commented Aug 5, 2026

Copy link
Copy Markdown
Member
  • if we received an invalid HELLO (or probably also READY) event, DSharpPlus would trigger the resume procedure. if the shard never successfully connected, this is fine, because the resume URL and session ID will be null and it'll trigger a hard reconnect, but if it did successfully connect before, it would reuse that resume URL and session ID for a resume attempt that may now be invalid. this would cause shards to stall infinitely in an attempt to resume before a session was established in the first place

  • if discord closed the gateway without an error code, DSharpPlus would crash the shard. we will now attempt to resume.

  • if discord sent an invalid gateway payload, DSharpPlus would crash the shard to restart from a clean slate. it now waits for five consecutive invalid events before rendering judgement so as to allow for transient errors

  • MultiShardOrchestrator would previously always immediately reconnect a failed shard without considering that many shards can fail at once. this adds a concurrency limit (currently of 1, since the actual gateway concurrency limit is more perfidious and 1 should guarantee success) to multi-sharded reconnects

  • This pull request did not involve AI in any way

  • All features in this pull request were tested.

currently untested because i can't test this, don't merge yet
this PR initially only intended to fix the first issue, but the list has grown

@akiraveliara akiraveliara added this to the v5.0 milestone Aug 5, 2026
@akiraveliara akiraveliara changed the title fix shards dying on receiving an invalid hello event improve gateway stability against new discord error conditions Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant