Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle case of non matching gun conn pids when receiving a gun_down message #611

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions lib/nostrum/shard/session.ex
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,18 @@ defmodule Nostrum.Shard.Session do
{:keep_state_and_data, {:next_event, :internal, :reconnect}}
end

def connected(
:info,
{:gun_down, old_conn, _proto, _reason, _killed_streams},
%{conn: new_conn}
# technically the guard is not needed because of the above clause,
# but it makes the intent a bit clearer
)
when old_conn != new_conn do
Logger.debug("Received gun_down message for a previous shard connection. Ignoring message.")
:keep_state_and_data
end

def connected(:cast, {request, payload}, %{conn: conn, stream: stream})
when request in [:status_update, :update_voice_state, :request_guild_members] do
:ok = :gun.ws_send(conn, stream, {:binary, payload})
Expand Down