Skip to content

Conversation

@rmachielse
Copy link
Contributor

@rmachielse rmachielse commented Sep 25, 2017

Summary

If a frontend for some reason tries to unsubscribe from a non existing action cable 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]:
/app/vendor/bundle/ruby/2.4.0/gems/actioncable-5.1.4/lib/action_cable/connection/subscriptions.rb:48:in `remove_subscription'
/app/vendor/bundle/ruby/2.4.0/gems/actioncable-5.1.4/lib/action_cable/connection/subscriptions.rb:44:in `remove'
/app/vendor/bundle/ruby/2.4.0/gems/actioncable-5.1.4/lib/action_cable/connection/subscriptions.rb:16:in `execute_command'
/app/vendor/bundle/ruby/2.4.0/gems/actioncable-5.1.4/lib/action_cable/connection/base.rb:85:in `dispatch_websocket_message' /app/vendor/bundle/ruby/2.4.0/gems/actioncable-5.1.4/lib/action_cable/server/worker.rb:58:in `block in invoke'

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"}]:
/app/vendor/bundle/ruby/2.4.0/gems/actioncable-5.1.4/lib/action_cable/connection/subscriptions.rb:76:in `find'
/app/vendor/bundle/ruby/2.4.0/gems/actioncable-5.1.4/lib/action_cable/connection/subscriptions.rb:44:in `remove'
/app/vendor/bundle/ruby/2.4.0/gems/actioncable-5.1.4/lib/action_cable/connection/subscriptions.rb:16:in `execute_command'
/app/vendor/bundle/ruby/2.4.0/gems/actioncable-5.1.4/lib/action_cable/connection/base.rb:85:in `dispatch_websocket_message'
/app/vendor/bundle/ruby/2.4.0/gems/actioncable-5.1.4/lib/action_cable/server/worker.rb:58:in `block in invoke

It's a subtle difference but it helps a lot when debugging.

@rails-bot
Copy link

Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @pixeltrix (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

This repository is being automatically checked for code quality issues using Code Climate. You can see results for this analysis in the PR status below. Newly introduced issues should be fixed before a Pull Request is considered ready to review.

Please see the contribution instructions for more information.

@rmachielse rmachielse force-pushed the patch-1 branch 2 times, most recently from 1155e91 to 28fffa0 Compare September 25, 2017 11:04
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"}]
@rmachielse
Copy link
Contributor Author

@pixeltrix can you or anyone else review this?

@kamipo kamipo merged commit b4dfc18 into rails:master Oct 5, 2017
@kamipo
Copy link
Member

kamipo commented Oct 5, 2017

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants