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!
Looks like there is mismatch in the \\__terminate__
function signature and what is being passed to it.
From the file , it expects the :inverse_channels
field in the call which is missing in your call.
So if you try adding an channels_inverse(second line below) field in your call(in iex), with a sample PID in the pid0 variable
Phoenix.Socket.__terminate__({:shutdown, :closed}, {
%{channels_inverse: %{}}, # this is dummy data added!!
%Phoenix.Socket{assigns: %{}, channel: MhrWeb.SearchChannel,
channel_pid: pid0, 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: pid0}
})
the function clause error goes away.
So, you will have to track where this function call without %{channels_inverse: %{}}
is coming from. Maybe your socket-related javascript files are not updated to phoenix 1.4?
想通了(这很愚蠢)...在我需要删除use Phoenix.Socket
每个通道模块中:/
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.