Skip to content

Commit e56ac19

Browse files
authoredJun 23, 2024
Merge pull request #611 from Th3-M4jor/handle-gun-down-when-different-gun-conn-pid
Handle case of non matching gun conn pids when receiving a gun_down message
2 parents 0142400 + 8f05e04 commit e56ac19

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
 

‎lib/nostrum/shard/session.ex

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,18 @@ defmodule Nostrum.Shard.Session do
388388
{:keep_state_and_data, {:next_event, :internal, :reconnect}}
389389
end
390390

391+
def connected(
392+
:info,
393+
{:gun_down, old_conn, _proto, _reason, _killed_streams},
394+
%{conn: new_conn}
395+
# technically the guard is not needed because of the above clause,
396+
# but it makes the intent a bit clearer
397+
)
398+
when old_conn != new_conn do
399+
Logger.debug("Received gun_down message for a previous shard connection. Ignoring message.")
400+
:keep_state_and_data
401+
end
402+
391403
def connected(:cast, {request, payload}, %{conn: conn, stream: stream})
392404
when request in [:status_update, :update_voice_state, :request_guild_members] do
393405
:ok = :gun.ws_send(conn, stream, {:binary, payload})

0 commit comments

Comments
 (0)