anycable / anycable-rails

AnyCable for Ruby on Rails applications
https://anycable.io
MIT License
495 stars 35 forks source link

reconnect option not forwarded in ActionCable::RemoteConnections::RemoteConnection#disconnect #195

Closed martin-kufner closed 6 months ago

martin-kufner commented 6 months ago

Tell us about your environment

Ruby version: 3.2

Rails version: 7.1.3

anycable gem version: 1.4.3

anycable-rails gem version: 1.4.3

What did you do?

Disconnecting user with no reconnect ActionCable.server.remote_connections.where(identity: User.find(...)).disconnect(reconnect: false)

What did you expect to happen?

reconnect is transmitted false

[ActionCable] Broadcasting to action_cable/. Z2lkOi8vcWIzL1BsYXllci8xODJhZTQzYy1jOGEyLTRkZWEtODk3My03YzBlNzdjOWNiNDMvYzI1ODA1NDgtMmMxYi00YWQ2LTkxM2MtM2QzYjkyMjhhOGY3:
{
     :type => "disconnect",
:reconnect => false
}

What actually happened?

reconnect is transmitted true

[ActionCable] Broadcasting to action_cable/Z2lkOi8vcWIzL1BsYXllci8xODJhZTQzYy1jOGEyLTRkZWEtODk3My03YzBlNzdjOWNiNDMvYzI1ODA1NDgtMmMxYi00YWQ2LTkxM2MtM2QzYjkyMjhhOGY3:
{
     :type => "disconnect",
:reconnect => true
}

Fix

anycable/rails/action_cable_ext/remote_connections.rb:10 in disconnect IS super() unless AnyCable::Rails.enabled? - super is called w/o arguments SHOULD BE super unless AnyCable::Rails.enabled? - without brackets, so super is called w/ arguments

martin-kufner commented 6 months ago

This does not affect when AnyCable::Rails is enabled.

palkan commented 6 months ago

Thanks for reporting! Fixed and will be released soon.

without brackets, so super is called w/ arguments

The feature (reconnect: ... support) has been added only in Rails 7.1, so we should still super() for older version.