Skip to content

Incompatibility with connection_pool >= 3.0: ArgumentError in reset_pool #2185

@ihabadham

Description

@ihabadham

A bug is a crash or incorrect behavior.

Environment

  1. Ruby version: 3.3.7
  2. Rails version: 8.0.4
  3. Shakapacker/Webpacker version: N/A (fresh Rails app, not yet installed)
  4. React on Rails version: 16.2.0.beta.13 (also affects 16.1.2)

Expected behavior

Running bin/rails generate react_on_rails:install or any Rails command should work when connection_pool gem version 3.0+ is installed.

Actual behavior

Rails crashes with:

connection_pool-3.0.2/lib/connection_pool.rb:48:in `initialize': wrong number of arguments (given 1, expected 0) (ArgumentError)
  from react_on_rails-16.2.0.beta.13/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb:16:in `new'
  from react_on_rails-16.2.0.beta.13/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb:16:in `reset_pool'

Root Cause

The connection_pool gem changed its API in version 3.0 to use keyword arguments instead of a hash.

In lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb:16:

# Current code (broken with connection_pool 3.0+)
@js_context_pool = ConnectionPool.new(options) { create_js_context }

# Fix: use keyword argument splatting
@js_context_pool = ConnectionPool.new(**options) { create_js_context }

Small, reproducible repo

# Create fresh Rails app
rails new ror_test_app --skip-git
cd ror_test_app

# Initialize git (required for installer)
git init && git add . && git commit -m "Initial"

# Add react_on_rails (this pulls in connection_pool 3.0.2)
echo 'gem "react_on_rails", "16.2.0.beta.13"' >> Gemfile
bundle install

# This crashes
bin/rails generate react_on_rails:install

Suggested Fix

Either:

  1. Update the code to use **options (keyword splat)
  2. Pin connection_pool to < 3.0 in the gemspec until the code is updated

Happy to submit a PR if helpful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions