absinthe_phoenix icon indicating copy to clipboard operation
absinthe_phoenix copied to clipboard

Malformed unsubscribe requests from `@absinthe/socket` causes GenServer crash.

Open JonRowe opened this issue 6 years ago • 1 comments

Hi there, I'm using the @absinthe/socket node package to talk to my subscriptions server side, but upon cleanup, (I'm not sure exactly how, I think its navigating away before requests are finished (or possibly evening starting)) its sending an unsubscribe request for the control channel without a subscription id, which crashes out because handle_in only handles "unsubscribe" for a specific connection id, despite the fact it could handle the socket cleanup without one.

Would you welcome a PR to fix this?

JonRowe avatar Jun 29 '19 12:06 JonRowe

GenServer terminating (FunctionClauseError): no function clause matching in Absinthe.Phoenix.Channel.handle_in/3 (Most recent call last)
File lib/absinthe/phoenix/channel.ex line 41 in Absinthe.Phoenix.Channel.handle_in/3 (absinthe_phoenix) args
  Absinthe.Phoenix.Channel.handle_in/3 (absinthe_phoenix) arguments
0 ""unsubscribe""
1 "%{}"
2 "%Phoenix.Socket{assigns: %{absinthe_pipeline: nil, absinthe_schema: MyApp.GraphQL.Schema, absinthe: %{opts: [context: %{id: "some_data", pubsub: MyApp.Endpoint}], pipeline: {Absinthe.Phoenix.Channel, :default_pipeline}, schema: MyApp.GraphQL.Schema}}, channel: Absinthe.Phoenix.Channel, channel_pid: #PID<0.915.0>, endpoint: MyApp.Endpoint, handler: MyApp.Socket, id: nil, join_ref: "1", joined: true, private: %{log_handle_in: :debug, log_join: :info}, pubsub_server: MyApp.PubSub, ref: "5", serializer: Phoenix.Transports.V2.WebSocketSerializer, topic: "absinthe:control", transport: Phoenix.Transports.WebSocket, transport_name: :websocket, transport_pid: #PID<0.914.0>, vsn: "2.0.0"}"

JonRowe avatar Jun 29 '19 12:06 JonRowe