elixirphoenix-frameworkphoenix-channels

Phoenix 1.4 Upgrade - (FunctionClauseError) no function clause matching in Phoenix.Socket.__terminate__/2


I recently upgraded my Phoenix app from 1.3 to 1.4.

Everything is great except that when I navigate away from a page I’m getting the following error:

[error] GenServer #PID<0.509.0> terminating
** (FunctionClauseError) no function clause matching in Phoenix.Socket.__terminate__/2
    (phoenix) lib/phoenix/socket.ex:544: Phoenix.Socket.__terminate__({:shutdown, :closed}, %Phoenix.Socket{assigns: %{}, channel: MhrWeb.SearchChannel, channel_pid: #PID<0.509.0>, endpoint: MhrWeb.Endpoint, handler: MhrWeb.UserSocket, id: nil, join_ref: "2", joined: true, private: %{log_handle_in: :debug, log_join: :info}, pubsub_server: Mhr.PubSub, ref: nil, serializer: Phoenix.Socket.V2.JSONSerializer, topic: "search:query", transport: :websocket, transport_pid: #PID<0.497.0>})
    (stdlib) gen_server.erl:673: :gen_server.try_terminate/3
    (stdlib) gen_server.erl:858: :gen_server.terminate/10
    (stdlib) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: {:"$gen_cast", :close}
State: %Phoenix.Socket{assigns: %{}, channel: MhrWeb.SearchChannel, channel_pid: #PID<0.509.0>, endpoint: MhrWeb.Endpoint, handler: MhrWeb.UserSocket, id: nil, join_ref: "2", joined: true, private: %{log_handle_in: :debug, log_join: :info}, pubsub_server: Mhr.PubSub, ref: nil, serializer: Phoenix.Socket.V2.JSONSerializer, topic: "search:query", transport: :websocket, transport_pid: #PID<0.497.0>}

I’ve tried implementing terminate in user_socket.ex and in search_channel.ex which handles the specific topics, but it hasn’t changed anything.

Any insight is very much appreciated!


Solution

  • Figured it out (it was dumb)... in each of my channel modules I needed to remove use Phoenix.Socket :/