connection_pool icon indicating copy to clipboard operation
connection_pool copied to clipboard

kwarg issue with Rails 8.1

Open taylorthurlow opened this issue 3 weeks ago • 1 comments

This happens when calling perform_async.

ArgumentError:
       unknown keyword: :name
     # /Users/taylorthurlow/.rbenv/versions/3.4.7/lib/ruby/gems/3.4.0/gems/connection_pool-3.0.1/lib/connection_pool.rb:48:in 'initialize'
     # /Users/taylorthurlow/.rbenv/versions/3.4.7/lib/ruby/gems/3.4.0/gems/sidekiq-7.3.9/lib/sidekiq/redis_connection.rb:34:in 'Class#new'
     # /Users/taylorthurlow/.rbenv/versions/3.4.7/lib/ruby/gems/3.4.0/gems/sidekiq-7.3.9/lib/sidekiq/redis_connection.rb:34:in 'Sidekiq::RedisConnection.create'
     # /Users/taylorthurlow/.rbenv/versions/3.4.7/lib/ruby/gems/3.4.0/gems/sidekiq-7.3.9/lib/sidekiq/config.rb:151:in 'Sidekiq::Config#new_redis_pool'
     # /Users/taylorthurlow/.rbenv/versions/3.4.7/lib/ruby/gems/3.4.0/gems/sidekiq-7.3.9/lib/sidekiq/config.rb:145:in 'Sidekiq::Config#local_redis_pool'

Potentially related to the fact that we're still using Sidekiq 7, still behind on the 8.x transition due to the change in redis version requirements.

taylorthurlow avatar Dec 05 '25 17:12 taylorthurlow

Fixed on main, release coming today.

mperham avatar Dec 05 '25 17:12 mperham

mem_cache_store gives an argument error because it doesn't splat the args in Rails 8.1.

ArgumentError: wrong number of arguments (given 1, expected 0) (ArgumentError)
/home/deploy/gorails/shared/bundle/ruby/3.4.0/gems/connection_pool-3.0.2/lib/connection_pool.rb:48:in 'initialize'
/home/deploy/gorails/shared/bundle/ruby/3.4.0/gems/activesupport-8.1.1/lib/active_support/cache/mem_cache_store.rb:62:in 'Class#new'

Rails main does splat the args.

excid3 avatar Dec 05 '25 21:12 excid3

I just updated to v3.0.2, and it does not work. I get the same error as @excid3 above.

It appears that for this to work, to following changes need to be made.

In activesupport-8.0.4/lib/active_support/cache/redis_cache_store.rb:

@redis = ::ConnectionPool.new(pool_options) { self.class.build_redis(**redis_options) }

Need to become:

@redis = ::ConnectionPool.new(**pool_options) { self.class.build_redis(**redis_options) }

For keywords args to work correctly, I've only verified it locally.

jtarchie avatar Dec 05 '25 22:12 jtarchie

In activesupport-8.0.4/lib/active_support/cache/redis_cache_store.rb:

@redis = ::ConnectionPool.new(pool_options) { self.class.build_redis(**redis_options) }

Need to become:

@redis = ::ConnectionPool.new(**pool_options) { self.class.build_redis(**redis_options) }

If you came to this issue for ArgumentError: wrong number of arguments (given 1, expected 0) (ArgumentError) from Rails, fatkodima fixed it with https://github.com/rails/rails/pull/56292 on 2025-12-05.

choznerol avatar Dec 08 '25 06:12 choznerol

3.0.2 solved the issue for me, but it looks like there are a decent number of similar issues depending on what Ruby and Sidekiq version you're on, so I'll leave it to Mike to close this at his discretion.

taylorthurlow avatar Dec 09 '25 17:12 taylorthurlow

having this issue with memcache

bin/rails aborted!
ArgumentError: wrong number of arguments (given 1, expected 0) (ArgumentError)
/app/vendor/bundle/ruby/3.4.0/gems/connection_pool-3.0.2/lib/connection_pool.rb:48:in 'initialize'
/app/vendor/bundle/ruby/3.4.0/gems/activesupport-8.1.1/lib/active_support/cache/mem_cache_store.rb:62:in 'Class#new'
/app/vendor/bundle/ruby/3.4.0/gems/activesupport-8.1.1/lib/active_support/cache/mem_cache_store.rb:62:in 'ActiveSupport::Cache::MemCacheStore.build_mem_cache'
/app/vendor/bundle/ruby/3.4.0/gems/activesupport-8.1.1/lib/active_support/cache/mem_cache_store.rb:93:in 'ActiveSupport::Cache::MemCacheStore#initialize'
/app/vendor/bundle/ruby/3.4.0/gems/activesupport-8.1.1/lib/active_support/cache.rb:91:in 'Class#new'
/app/vendor/bundle/ruby/3.4.0/gems/activesupport-8.1.1/lib/active_support/cache.rb:91:in 'ActiveSupport::Cache.lookup_store'
/app/vendor/bundle/ruby/3.4.0/gems/railties-8.1.1/lib/rails/application/bootstrap.rb:85:in 'block in <module:Bootstrap>'
/app/vendor/bundle/ruby/3.4.0/gems/railties-8.1.1/lib/rails/initializable.rb:24:in 'BasicObject#instance_exec'
/app/vendor/bundle/ruby/3.4.0/gems/railties-8.1.1/lib/rails/initializable.rb:24:in 'Rails::Initializable::Initializer#run'
/app/vendor/bundle/ruby/3.4.0/gems/railties-8.1.1/lib/rails/initializable.rb:103:in 'block in Rails::Initializable#run_initializers'

jurgens avatar Dec 13 '25 13:12 jurgens