Skip to content

Commit

Permalink
Merge pull request #566 from Kraigie/try-resume-only-if-possible
Browse files Browse the repository at this point in the history
Only attempt resume if the gateway says we can
  • Loading branch information
jb3 authored May 4, 2024
2 parents 6019123 + e303f2b commit b101e10
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/nostrum/shard/event.ex
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,14 @@ defmodule Nostrum.Shard.Event do
end
end

def handle(:invalid_session, _payload, state) do
Logger.info("INVALID_SESSION")
{{state, Payload.identity_payload(state)}, []}
def handle(:invalid_session, %{d: _can_resume? = true}, state) do
Logger.info("Invalid but resumable session. Attempting to resume at #{state.session}")
{{state, Payload.resume_payload(state)}, []}
end

def handle(:invalid_session, %{d: _can_resume? = false}, state) do
Logger.info("Invalid and un-resumable session at #{state.session}. Events may be lost.")
{{state, :reconnect}, []}
end

def handle(:reconnect, _payload, state) do
Expand Down

0 comments on commit b101e10

Please # to comment.