annotaterb icon indicating copy to clipboard operation
annotaterb copied to clipboard

Mounting ActionCable leads to weird annotation

Open epugh opened this issue 1 year ago • 10 comments

Describe your problem here.

Commands

See my Quepid routes here: https://github.com/o19s/quepid/blob/main/config/routes.rb#L7

I have to explicitly mount ActionCable (for some reason): mount ActionCable.server => '/cable' and maybe that is part of it?

I would not expect to see all the details, it's like a method on ActionCable is missing!

#<ActionCable::Server::Base:0x00007f9d8a193ac8 @config=#<ActionCable::Server TRUNCATED FOR LENGTH

Version

  • annotaterb version 4.13
  • rails version 8.0.0!
  • ruby version 3.3.5
  • database version mysql 8
  • database adapter version (if available) mysql2

epugh avatar Nov 08 '24 12:11 epugh

I just ported over from the original Annotate, thanks for taking up the mantle of supporting this!

epugh avatar Nov 08 '24 12:11 epugh

Hi @epugh thanks for reporting. I'll take a look tomorrow and see what might be going on.

drwl avatar Nov 11 '24 01:11 drwl

Took an initial look and I have to upgrade my local dummy app to Rails 8. I'll try and have another update for you tomorrow -- apologies for the delay.

drwl avatar Nov 13 '24 06:11 drwl

No worries! I think everyone who maintains a gem related to rails is going through their update cycle ;-).

epugh avatar Nov 13 '24 15:11 epugh

@epugh so I finally got it working locally. This isn't on annotaterb's side, but rather a Rails routes issue with what looks like engines. I don't have another full fledged app with engines to test it with. But to verify, if you do bin/rails routes (which annotaterb uses):

bin/rails routes
                Prefix Verb   URI Pattern                       Controller#Action
                              /cable                            #<ActionCable::Server::Base:0x000000012a3301f0 @config=#<ActionCable::Server::Configuration:0x000000012a7e1d20 @log_tags=[], @connection_class=#<Proc:0x000000012a8890e8 /Users/leea/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/actioncable-8.0.0/lib/action_cable/engine.rb:55 (lambda)>, @worker_pool_size=4, @disable_request_forgery_protection=false, @allow_same_origin_as_host=true, @filter_parameters=[:passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn, :cvv, :cvc], @health_check_application=#<Proc:0x000000012a8892a0 /Users/leea/.rbenv/versions/3.3.3/lib/ruby/gems/3.3.0/gems/actioncable-8.0.0/lib/action_cable/engine.rb:31 (lambda)>, @logger=#<ActiveSupport::BroadcastLogger:0x000000011fbbc8d8 @broadcasts=[#<ActiveSupport::Logger:0x000000011ffc8da0 @level=0, @progname=nil, @default_formatter=#<Logger::Formatter:0x000000011fd4c298 @datetime_format=nil>, @formatter=#<ActiveSupport::Logger::SimpleFormatter:0x000000011fbbd508 @datetime_format=nil>, @logdev=#<Logger::LogDevice:0x000000011ffce520 @shift_period_suffix="%Y%m%d", @shift_size=104857600, @shift_age=1, @filename="/Users/leea/personal/annotaterb/spec/dummyapp/log/development.log", @dev=#<File:/Users/leea/personal/annotaterb/spec/dummyapp/log/development.log>, @binmode=false, @reraise_write_errors=[], @mon_data=#<Monitor:0x000000011fd4b2d0>, @mon_data_owner_object_id=3220>, @level_override={}>], @progname="Broadcast", @formatter=#<ActiveSupport::Logger::SimpleFormatter:0x000000011fbbd508 @datetime_format=nil>>, @mount_path="/cable", @precompile_assets=true, @allowed_request_origins=/https?:\/\/localhost:\d+/>, @mutex=#<Monitor:0x000000012a8eeda8>, @pubsub=nil, @worker_pool=nil, @event_loop=nil, @remote_connections=nil>
                  root GET    /                                 articles#index
                       ...
                       POST   /singular_resource(.:format)      singular_resources#create

drwl avatar Nov 15 '24 01:11 drwl

This behavior seems like it also exists in Rails 7.0.8.4

drwl avatar Nov 15 '24 01:11 drwl

Interesting... so it seems like a bug? I'm surprised it's been there because it seems really obvious?

epugh avatar Nov 15 '24 02:11 epugh

I haven't really used action cable in Rails apps and so I'm not knowledgable in this. So this might be worth reporting to the Rails team. In your mind, what should the route /cable route mount to? Is there a specific action cable controller?

drwl avatar Nov 15 '24 02:11 drwl

I think it would mount to /cable and not have all the extra cruft in the Controller#Action section. I think it would just say somehting along the lines of ActionCable::Server::Base:0x000000012a3301f0

epugh avatar Nov 15 '24 11:11 epugh

Going through all issues -- I think the behavior isn't wrong but definitely not ideal. I'm adding the enhancement label if anyone wants to try working on this.

drwl avatar Feb 17 '25 02:02 drwl