Skip to content

Conversation

@ihabadham
Copy link
Contributor

@ihabadham ihabadham commented Dec 9, 2025

Summary

  • Fix ArgumentError: wrong number of arguments (given 1, expected 0) when using connection_pool gem version 3.0+
  • Use keyword argument splatting (**options) instead of positional hash argument when initializing ConnectionPool

Fixes #2185

Background

The connection_pool gem changed its API in version 3.0 to use keyword arguments instead of positional arguments. This breaking change caused React on Rails to fail during Rails boot when connection_pool 3.0+ was installed.

This is the same fix that Rails applied for their RedisCacheStore.

Test plan

  • Verified fix works with connection_pool 3.0.2 using fresh Rails 8 app with local gem
  • The **options syntax is backwards compatible with older versions of connection_pool
  • RuboCop passes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Refactor
    • Improved code structure in server rendering components for enhanced maintainability.

✏️ Tip: You can customize this high-level summary in your review settings.

The connection_pool gem v3.0 changed its API from positional hash
arguments to keyword arguments. This caused an ArgumentError when
initializing the server rendering pool.

The fix uses the double-splat operator (**options) which works with
both old and new versions of connection_pool:
- Old versions (< 3.0): Accepts hash as positional argument
- New versions (>= 3.0): Requires keyword arguments

Fixes #2185

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 9, 2025

Walkthrough

Updated ConnectionPool initialization in the server rendering pool module to use keyword argument splatting (**options) instead of positional hash argument. This resolves incompatibility with connection_pool gem version 3.0+, which changed its API to require keyword arguments.

Changes

Cohort / File(s) Summary
connection_pool 3.0+ compatibility fix
react_on_rails/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb
Updated ConnectionPool instantiation in reset_pool method from positional hash argument to keyword argument splatting (**options)

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

  • Single-file change affecting only the pool initialization line
  • Straightforward API compatibility fix with no logic changes
  • Verify that keyword argument splatting correctly passes all pool configuration options

Poem

🐰 The pool was broken, oh what a plight,
But keyword splats made it right!
From positional to **options true,
Connection pool 3.0, we got through! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing compatibility with connection_pool >= 3.0 by updating API calls.
Linked Issues check ✅ Passed The code change directly addresses the linked issue #2185 by updating ConnectionPool initialization to use keyword argument splatting (**options) instead of positional hash arguments, which resolves the ArgumentError in connection_pool 3.0+.
Out of Scope Changes check ✅ Passed The changes are limited to the specific file and issue scope, updating only the ConnectionPool initialization syntax without introducing unrelated modifications.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-connection-pool-3.0-compatibility

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3acff76 and 76494b1.

📒 Files selected for processing (1)
  • react_on_rails/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{rb,rake}

📄 CodeRabbit inference engine (CLAUDE.md)

ALWAYS run bundle exec rubocop and fix ALL violations before every commit/push

Files:

  • react_on_rails/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb
**/*

📄 CodeRabbit inference engine (CLAUDE.md)

ALWAYS ensure files end with a newline character before committing/pushing

Files:

  • react_on_rails/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb
🧠 Learnings (2)
📓 Common learnings
Learnt from: CR
Repo: shakacode/react_on_rails PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T08:05:17.804Z
Learning: Applies to /CHANGELOG*.md : Use changelog format: `[PR 1818](https://github.com/shakacode/react_on_rails/pull/1818) by [username](https://github.com/username)` (no hash in PR number)
📚 Learning: 2025-11-25T08:05:17.804Z
Learnt from: CR
Repo: shakacode/react_on_rails PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-25T08:05:17.804Z
Learning: Applies to /CHANGELOG.md : Update `/CHANGELOG.md` for user-visible changes (features, bug fixes, breaking changes, deprecations, performance improvements) to the open-source React on Rails gem and npm package

Applied to files:

  • react_on_rails/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: build-dummy-app-webpack-test-bundles (3.4, 22, latest)
  • GitHub Check: rspec-package-tests (3.4, latest)
  • GitHub Check: build
  • GitHub Check: claude-review
🔇 Additional comments (1)
react_on_rails/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb (1)

11-17: Keyword-arg ConnectionPool initialization fix looks correct

Using ConnectionPool.new(**options) here is the right way to satisfy the keyword-arg initializer introduced in connection_pool 3.x while keeping the existing options construction untouched. This should resolve the ArgumentError you were hitting during Rails boot without changing pool behavior.

Given this touches a gem API and Ruby keyword-arg semantics, please double-check against your supported Ruby / connection_pool version matrix, but conceptually this change is solid and in line with how Rails handles similar cases.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@claude
Copy link

claude bot commented Dec 9, 2025

Code Review

Summary

This PR fixes a critical compatibility issue with connection_pool gem version 3.0+ by using keyword argument splatting (**options) instead of positional hash arguments. The fix is minimal, correct, and backward compatible.


✅ Code Quality & Best Practices

Excellent:

  • Minimal change principle: Only modified the exact line needed (line 16)
  • Follows established pattern: Rails applied the same fix for their RedisCacheStore
  • Clean diff: Single-line change makes the fix easy to review and understand
  • Preserves existing structure: No unnecessary refactoring or scope creep

Code correctness:
The change from:

ConnectionPool.new(options) { create_js_context }

to:

ConnectionPool.new(**options) { create_js_context }

is the correct way to handle the connection_pool 3.0 API change. The double-splat operator (**) converts the hash into keyword arguments, which is what version 3.0 now requires.


✅ Backward Compatibility

Verified: The **options syntax is backward compatible with connection_pool < 3.0 because:

  1. Ruby's keyword argument splatting works with older versions that accepted a hash
  2. The options hash contains only the exact keys (size, timeout) that ConnectionPool expects
  3. This is the same approach Rails took in their codebase

✅ Bug Fix Validation

Issue correctly identified:

  • The PR description accurately describes the problem
  • Root cause analysis is correct (connection_pool 3.0 breaking change)
  • Reproduction steps are clear and verifiable
  • References the upstream changelog

Fix addresses the root cause:

  • Directly resolves the ArgumentError: wrong number of arguments
  • Unblocks Rails boot and generator usage
  • No workarounds or temporary patches

🔍 Test Coverage

Current state:

  • ✅ Existing integration tests in spec/dummy/spec/requests/server_render_check_spec.rb exercise the reset_pool code path
  • ✅ The tests verify server-side rendering works, which requires ConnectionPool initialization
  • ✅ Manual testing confirmed in PR description

Recommendation for future enhancement (NOT blocking):
Consider adding a specific test that verifies ConnectionPool initialization with both old and new gem versions. This could be a regression test in spec/react_on_rails/server_rendering_pool/ruby_embedded_java_script_spec.rb (if one exists or gets created).

Example structure:

describe 'ConnectionPool initialization' do
  it 'initializes pool with keyword arguments' do
    expect { described_class.reset_pool }.not_to raise_error
    expect(described_class.instance_variable_get(:@js_context_pool)).to be_a(ConnectionPool)
  end
end

However, since existing integration tests cover this, it's not critical for this PR.


✅ Security Considerations

No security concerns:

  • Change is purely syntactic (positional hash → keyword arguments)
  • No changes to validation, sanitization, or data flow
  • No new dependencies or external inputs

✅ Performance Considerations

No performance impact:

  • Identical runtime behavior (just different calling convention)
  • No changes to pool size, timeout, or connection management
  • No additional allocations or operations

📋 Pre-merge Checklist

Based on CLAUDE.md requirements:

  • RuboCop: PR description confirms RuboCop passes
  • Minimal change: No unnecessary formatting or refactoring
  • Backward compatibility: **options works with older connection_pool versions
  • Trailing newlines: File already ends with newline (verified in diff)
  • CI status: Currently running (lint job in progress)

📝 Documentation

Recommendation: Consider adding a note to the CHANGELOG under "Bug Fixes":

#### Bug Fixes
- [PR 2186](https://github.com/shakacode/react_on_rails/pull/2186) by [example-user](https://github.com/example-user): Fix compatibility with connection_pool >= 3.0 by using keyword argument splatting

This is a user-visible bug fix (blocks Rails boot), so it should be documented per CLAUDE.md guidelines.


✅ Final Recommendation

APPROVE AND MERGE once CI passes.

This is a textbook example of a minimal, correct bug fix:

  • Addresses a critical issue (Rails boot failure)
  • Minimal code change (1 line)
  • Backward compatible
  • Well-tested by existing integration tests
  • Follows established patterns (same fix as Rails)

Great work! 🎉


🤖 Review generated with Claude Code

@claude
Copy link

claude bot commented Dec 9, 2025

Code Review - PR #2186

Thank you for this PR! This is an excellent fix for a critical compatibility issue. Here's my detailed review:

✅ Strengths

  1. Correct Fix: The change from ConnectionPool.new(options) to ConnectionPool.new(**options) is exactly right. This uses keyword argument splatting, which is compatible with both old (< 3.0) and new (>= 3.0) versions of the connection_pool gem.

  2. Well-Documented: The PR description clearly explains the problem, references the upstream change in connection_pool 3.0, and links to similar fixes in Rails core.

  3. Minimal Change: Single-line fix that addresses the root cause without over-engineering.

  4. Backwards Compatible: The **options syntax works with both old and new versions of connection_pool, making this a safe change.

📝 Suggestions

1. Add CHANGELOG Entry (Required)

According to the project's CLAUDE.md guidelines, user-visible bug fixes should be documented in CHANGELOG.md. This is definitely user-visible since it fixes a crash on Rails boot.

Suggested entry under #### Fixed section in Unreleased:

#### Fixed

- **Compatibility with connection_pool >= 3.0**: Fixed `ArgumentError: wrong number of arguments` crash during Rails boot when using connection_pool gem version 3.0+. Updated to use keyword argument splatting (`**options`) in `ConnectionPool.new` initialization. [PR 2186](https://github.com/shakacode/react_on_rails/pull/2186) by [<your-github-username>](https://github.com/<your-github-username>).

You can use the /update-changelog command for guided assistance with formatting.

2. Consider Test Coverage (Nice to Have)

I noticed there are no existing tests for RubyEmbeddedJavaScript.reset_pool. While not required to merge this PR, it would be valuable to add a test that:

  • Verifies reset_pool can be called without errors
  • Tests compatibility with both connection_pool versions (if feasible)

However, given this is a bug fix for an external API change and manual testing was done with a fresh Rails 8 app, the lack of automated tests is acceptable for now.

3. Verify Pro Package (Already Confirmed ✅)

I checked and confirmed the Pro package doesn't use ConnectionPool.new directly, so no changes are needed there. Good to go!

🔍 Code Quality Assessment

  • Style: Follows Ruby conventions ✅
  • Security: No security concerns ✅
  • Performance: No performance impact (same runtime behavior) ✅
  • Compatibility: Backwards compatible ✅

📋 Pre-Merge Checklist

Before merging, please ensure:

  • Add CHANGELOG.md entry (see suggestion above)
  • Verify RuboCop passes (you mentioned it does ✅)
  • Manual testing completed (you mentioned it works ✅)

🚀 Recommendation

Approve and merge after adding the CHANGELOG entry. This is a critical bug fix that unblocks users who have connection_pool 3.0+ installed.

Great work identifying the issue and providing a clean fix! 🎉


Review conducted following the project's CLAUDE.md guidelines and conventions.

@claude
Copy link

claude bot commented Dec 9, 2025

Code Review - PR 2186

Summary

This PR fixes a critical compatibility issue with connection_pool >= 3.0. The fix is minimal, correct, and backward compatible.

Strengths

  • Correctly addresses connection_pool 3.0 API breaking change
  • Backward compatible with older versions
  • Follows existing codebase patterns (keyword argument splatting used extensively)
  • Well-documented issue with clear reproduction steps
  • Minimal one-line change reduces risk

Suggestions

1. Add CHANGELOG Entry

This is a user-facing bug fix that should be documented in CHANGELOG.md under Unreleased > Fixed:

  • Fixed ArgumentError when using connection_pool >= 3.0 by updating ServerRenderingPool to use keyword argument splatting. PR 2186 by ihabadham. Fixes issue 2185.

2. Verify RuboCop

Run bundle exec rubocop before committing (per CLAUDE.md)

3. Monitor CI After Merge

Monitor CI for 30 minutes after merge (per CLAUDE.md)

Security and Performance

  • Security: No concerns
  • Performance: No impact

Conclusion

Recommendation: Approve with changelog update

Excellent fix! The code change is correct and the only missing piece is a CHANGELOG entry.

Great work identifying and fixing this! 🎉

@claude
Copy link

claude bot commented Dec 9, 2025

Code Review for PR #2186

Summary

This PR fixes a critical compatibility issue with connection_pool gem version 3.0+ by using keyword argument splatting (**options) instead of a positional hash argument. This is a well-executed fix with excellent documentation.


✅ Strengths

  1. Correct Fix: The change from ConnectionPool.new(options) to ConnectionPool.new(**options) is exactly right and matches the fix Rails applied for the same issue (rails/rails#56292).

  2. Backwards Compatible: The **options keyword splat syntax is backwards compatible with older versions of connection_pool (< 3.0), so this won't break existing installations.

  3. Well-Documented: The PR description clearly explains:

    • What broke and why
    • The upstream API change in connection_pool 3.0
    • Test plan with verification steps
    • Reference to Rails' fix for the same issue
  4. Minimal Scope: The fix touches only the necessary line of code - no over-engineering or unnecessary refactoring.

  5. CI Passing: All tests are passing, demonstrating the fix works.


📝 Observations & Suggestions

1. Changelog Entry Needed

This is a user-visible bug fix that should be documented:

#### Bug Fixes

- [PR 2186](https://github.com/shakacode/react_on_rails/pull/2186) by [ihabadham](https://github.com/ihabadham): Fix compatibility with `connection_pool` gem version 3.0+. Fixes `ArgumentError: wrong number of arguments` when using `connection_pool` 3.0+ during Rails boot.

Per CLAUDE.md, this qualifies for changelog inclusion as it's a user-visible bug fix.

2. Test Coverage Gap (Low Priority)

The reset_pool method doesn't appear to have direct unit tests. While integration tests exist (and are passing), consider adding a spec to test:

  • Pool creation with different configuration options
  • Compatibility with both old and new connection_pool versions

This is not blocking for this PR, but could be a future improvement.

3. Dependency Version Constraint (Informational)

The gemspec has s.add_dependency "connection_pool" without a version constraint. This means:

  • ✅ Users can use any version (including 3.0+) - good for flexibility
  • ⚠️ No guarantee against future breaking changes

This is actually fine given your backwards-compatible fix, but worth noting for future reference.


🔒 Security & Performance

  • Security: No security concerns. This is a straightforward API compatibility fix.
  • Performance: No performance impact. The keyword splat has negligible overhead and the pool creation happens once during initialization.

✅ Recommendation

LGTM - Ready to Merge

This is an excellent fix that:

  • Solves a real user-facing bug
  • Is backwards compatible
  • Follows best practices
  • Has proper documentation

Action Items Before Merge:

  1. Add changelog entry to /CHANGELOG.md (see suggestion above)
  2. Merge when ready

📚 References

Great work on identifying and fixing this quickly! 🎉

@claude
Copy link

claude bot commented Dec 9, 2025

Code Review - Excellent Fix! 🎉

Summary

This PR correctly fixes a critical compatibility issue with connection_pool >= 3.0. The fix is minimal, correct, and backward compatible. Great work!


✅ Strengths

  1. Correct Fix: Using **options for keyword argument splatting is exactly right and matches the fix Rails applied (rails/rails#56292)

  2. Backward Compatible: The **options syntax works with both old (< 3.0) and new (>= 3.0) versions of connection_pool

  3. Well-Documented: Clear explanation of the issue, root cause, test plan, and references to upstream changes

  4. Minimal Scope: Single-line change that addresses the root cause without over-engineering

  5. Proper Testing: Manual testing with fresh Rails 8 app, and existing integration tests cover this code path


📝 Suggestions

1. Add CHANGELOG Entry

Per the project's CLAUDE.md guidelines, user-visible bug fixes should be documented. Please add this to /CHANGELOG.md under the #### Fixed section in Unreleased:

- **Compatibility with connection_pool >= 3.0**: Fixed `ArgumentError: wrong number of arguments` crash during Rails boot when using connection_pool gem version 3.0+. Updated to use keyword argument splatting (`**options`) in ServerRenderingPool initialization. [PR 2186](https://github.com/shakacode/react_on_rails/pull/2186) by [ihabadham](https://github.com/ihabadham).

You can use the /update-changelog command for guided assistance with formatting.

2. Monitor After Merge

Per CLAUDE.md guidelines, please monitor CI for 30 minutes after your PR merges to ensure it doesn't break master.


🔍 Code Quality Assessment

  • Security: No concerns ✅
  • Performance: No impact (same runtime behavior) ✅
  • Style: Follows Ruby conventions ✅
  • Compatibility: Backward compatible ✅

🚀 Recommendation

APPROVE - Ready to merge after adding the CHANGELOG entry.

This is a textbook example of a minimal, correct bug fix that unblocks users experiencing Rails boot failures. Excellent work identifying the issue and providing a clean solution!


Review conducted following the project's CLAUDE.md guidelines.

@claude
Copy link

claude bot commented Dec 9, 2025

Code Review for PR #2186: Fix compatibility with connection_pool >= 3.0

Summary

This is an excellent fix for a critical compatibility issue. The change is minimal, correct, and well-researched.

Code Quality: EXCELLENT

Strengths:

  • Minimal change: Single character addition (**) - perfect example of surgical fix
  • Backwards compatible: Keyword argument splatting works with both old and new connection_pool versions
  • Well-researched: PR description references the exact upstream change in connection_pool 3.0 and Rails similar fix
  • Matches Rails pattern: Using the same approach as Rails PR 56292 ensures consistency with ecosystem standards

Code location: react_on_rails/lib/react_on_rails/server_rendering_pool/ruby_embedded_java_script.rb:16

Bug Fix Validation: CONFIRMED

Root cause correctly identified:

  • connection_pool 3.0 changed from positional hash arg to keyword args
  • The current code passes a hash as a positional argument, which fails with ArgumentError
  • Using **options splats the hash into keyword arguments, satisfying the new API

Impact: This bug prevents all Rails apps from booting when connection_pool >= 3.0 is installed (including fresh Rails 8 apps), making this a CRITICAL fix.

Security: NO CONCERNS

No security implications - purely an API compatibility fix.

Performance: NO IMPACT

The ** operator has negligible overhead and does not change the runtime behavior.

Test Coverage: ADEQUATE

Existing coverage:

  • Integration tests in spec/dummy/spec/requests/server_render_check_spec.rb verify server rendering works
  • These tests exercise reset_pool indirectly through server rendering requests
  • CI shows all checks passing

Manual verification noted in PR:

  • Author tested with connection_pool 3.0.2 in fresh Rails 8 app
  • Verified backwards compatibility with older versions

Checklist Items

Based on CLAUDE.md requirements:

  • RuboCop: Passing (as shown in test plan)
  • CHANGELOG.md: Missing entry - this is a user-visible bug fix that should be documented
  • Code formatting: No manual formatting, change is minimal
  • Files end with newline: Auto-handled by git hooks

Recommendations

  1. REQUIRED: Add CHANGELOG entry

Per CLAUDE.md section on Changelog Guidelines, this user-visible bug fix needs documentation:

Add to the Unreleased section under [16.2.0] in /CHANGELOG.md:

  1. OPTIONAL: Consider gemspec constraint

Currently the gemspec has no version constraint. Since this fix makes the code work with all versions of connection_pool, the current unconstrained dependency is fine.

  1. OPTIONAL: Add unit test

While existing integration tests cover this indirectly, consider adding explicit test for ConnectionPool initialization with keyword arguments. This is nice-to-have but not critical.

Verdict: APPROVE with minor CHANGELOG addition

This is a high-quality, well-researched fix for a critical bug. The only required change before merge is adding the CHANGELOG entry.

Merge recommendation: APPROVE after CHANGELOG update.

Great work @ihabadham!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Incompatibility with connection_pool >= 3.0: ArgumentError in reset_pool

2 participants