From 4b629eca21fbecf9a49f00f3933ad4c28ad78600 Mon Sep 17 00:00:00 2001 From: Richard Machielse Date: Mon, 25 Sep 2017 13:03:52 +0200 Subject: ActionCable: use find method when unsubscribing If a frontend for some reason tries to unsubscribe from a non existing subscription, the following error is logged: Could not execute command from ({"command"=>"unsubscribe", "identifier"=>"{\"channel\":\"SomeChannel\"}"}) [NoMethodError - undefined method `unsubscribe_from_channel' for nil:NilClass] Instead, it will now properly log: Could not execute command from ({"command"=>"unsubscribe", "identifier"=>"{\"channel\":\"SomeChannel\"}"}) [RuntimeError - Unable to find subscription with identifier: {"channel":"SomeChannel"}] --- actioncable/lib/action_cable/connection/subscriptions.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actioncable/lib/action_cable/connection/subscriptions.rb') diff --git a/actioncable/lib/action_cable/connection/subscriptions.rb b/actioncable/lib/action_cable/connection/subscriptions.rb index faafd6d0a6..bb8d64e27a 100644 --- a/actioncable/lib/action_cable/connection/subscriptions.rb +++ b/actioncable/lib/action_cable/connection/subscriptions.rb @@ -43,7 +43,7 @@ module ActionCable def remove(data) logger.info "Unsubscribing from channel: #{data['identifier']}" - remove_subscription subscriptions[data["identifier"]] + remove_subscription find(data) end def remove_subscription(subscription) -- cgit v1.2.3