diff options
author | rinpatch <rinpatch@sdf.org> | 2020-09-10 13:48:24 +0300 |
---|---|---|
committer | rinpatch <rinpatch@sdf.org> | 2020-09-10 21:14:23 +0300 |
commit | e16e8f98169f822416c18778abfa8495a486c8f2 (patch) | |
tree | 8ae04ecf800fdec6aa488507be85ccc99116679e | |
parent | cb06e98da27994ac8034f3ba387b6eeaf8a2c48f (diff) | |
download | pleroma-e16e8f98169f822416c18778abfa8495a486c8f2.tar.gz |
Websocket handler: do not raise if handler is terminated before switching protocols
Closes #2131
-rw-r--r-- | lib/pleroma/web/mastodon_api/websocket_handler.ex | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/pleroma/web/mastodon_api/websocket_handler.ex b/lib/pleroma/web/mastodon_api/websocket_handler.ex index e6010bb4a..5090d9622 100644 --- a/lib/pleroma/web/mastodon_api/websocket_handler.ex +++ b/lib/pleroma/web/mastodon_api/websocket_handler.ex @@ -100,6 +100,10 @@ defmodule Pleroma.Web.MastodonAPI.WebsocketHandler do {:reply, :ping, %{state | timer: nil, count: 0}, :hibernate} end + # State can be `[]` only in case we terminate before switching to websocket, + # we already log errors for these cases in `init/1`, so just do nothing here + def terminate(_reason, _req, []), do: :ok + def terminate(reason, _req, state) do Logger.debug( "#{__MODULE__} terminating websocket connection for user #{ |