anycable / anycable-rails

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

Fix broadcast logging in rails 7.1+ #192

Closed iuri-gg closed 11 months ago

iuri-gg commented 11 months ago

What is the purpose of this pull request?

Fixes issue with Rails 7.1. Previous fix sets Anycable.logger to an instance of BroadcastLogger with two loggers (console and previous instance of BroadcastLogger). This nested BroadcastLogger breaks with following error:

undefined method `current_tags' for nil:NilClass:
/Users/iuri/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actioncable-7.1.1/lib/action_cable/connection/tagged_logger_proxy.rb:25:in `tag'
/Users/iuri/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actioncable-7.1.1/lib/action_cable/connection/tagged_logger_proxy.rb:40:in `log'
/Users/iuri/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/actioncable-7.1.1/lib/action_cable/connection/tagged_logger_proxy.rb:34:in `block (2 levels) in <class:TaggedLoggerProxy>'
/Users/iuri/.rbenv/versions/3.2.2/lib/ruby/gems/3.2.0/gems/anycable-rails-core-1.4.1/lib/anycable/rails/connection.rb:89:in `handle_open'
...

What changes did you make? (overview)

Use official #broadcast_to API

Is there anything you'd like reviewers to focus on?

Checklist

palkan commented 11 months ago

Thanks! Just in time for the release.