New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ActionCable: use find method when unsubscribing #30702

Merged
merged 1 commit into from Oct 5, 2017

Conversation

Projects
None yet
4 participants
@rmachielse
Contributor

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

This comment has been minimized.

Show comment
Hide comment
@rails-bot

rails-bot Sep 25, 2017

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.

rails-bot commented Sep 25, 2017

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.

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"}]
@rmachielse

This comment has been minimized.

Show comment
Hide comment
@rmachielse

rmachielse Oct 5, 2017

Contributor

@pixeltrix can you or anyone else review this?

Contributor

rmachielse commented Oct 5, 2017

@pixeltrix can you or anyone else review this?

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

2 checks passed

codeclimate All good!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@kamipo

This comment has been minimized.

Show comment
Hide comment
@kamipo

kamipo Oct 5, 2017

Member

Thanks!

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