From 3966f7d09f0b7390d281c68f60b9f14b5686a49f Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Sat, 6 Dec 2025 21:06:43 +0000 Subject: [PATCH 1/5] test: add appraisal gemfile for `connection_pool` v2 --- Appraisals | 4 ++++ gemfiles/connection_pool_2.gemfile | 7 +++++++ 2 files changed, 11 insertions(+) create mode 100644 gemfiles/connection_pool_2.gemfile diff --git a/Appraisals b/Appraisals index 77688348..50a89c68 100644 --- a/Appraisals +++ b/Appraisals @@ -19,3 +19,7 @@ end appraise 'shakapacker' do gem 'shakapacker', '7.2.0' end + +appraise 'connection_pool_2' do + gem 'connection_pool', '~> 2' +end diff --git a/gemfiles/connection_pool_2.gemfile b/gemfiles/connection_pool_2.gemfile new file mode 100644 index 00000000..e2237f5c --- /dev/null +++ b/gemfiles/connection_pool_2.gemfile @@ -0,0 +1,7 @@ +# This file was generated by Appraisal + +source "http://rubygems.org" + +gem "connection_pool", "~> 2" + +gemspec path: "../" From 480199803ea24ebf6a02be4df19af4edab92534e Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Sat, 6 Dec 2025 21:21:37 +0000 Subject: [PATCH 2/5] test: add coverage for `connection_pool` v3 --- .github/workflows/ruby.yml | 60 ++++ Appraisals | 4 +- ...ol_2.gemfile => connection_pool_3.gemfile} | 2 +- gemfiles/connection_pool_3.gemfile.lock | 278 ++++++++++++++++++ 4 files changed, 341 insertions(+), 3 deletions(-) rename gemfiles/{connection_pool_2.gemfile => connection_pool_3.gemfile} (75%) create mode 100644 gemfiles/connection_pool_3.gemfile.lock diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 74452782..eb44e6eb 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -119,3 +119,63 @@ jobs: - run: bundle exec rake test env: NODE_OPTIONS: --openssl-legacy-provider + + test_connection_pool_v3: + needs: check_react_and_ujs + strategy: + fail-fast: false + matrix: + js_package_manager: + - name: npm + installer: npm + - name: yarn_classic + installer: yarn + - name: pnpm + installer: pnpm + - name: bun + installer: bun + ruby: [3.2] + gemfile: [connection_pool_3] + runs-on: ubuntu-latest + env: + # $BUNDLE_GEMFILE must be set at the job level, so it is set for all steps + BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile + # Workaround b/c upgrading Minitest broke some mocking expectations + # having to do with automatic kwarg splatting + MT_KWARGS_HACK: 1 + PACKAGE_JSON_FALLBACK_MANAGER: ${{ matrix.js_package_manager.name }} + SHAKAPACKER_USE_PACKAGE_JSON_GEM: true + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + - uses: actions/setup-node@v3 + - run: sudo npm -g install yalc ${{ matrix.js_package_manager.installer }} + - run: yalc publish + - name: Save root node_modules to cache + uses: actions/cache@v3 + with: + path: node_modules + key: package-node-modules-cache-${{ hashFiles('yarn.lock') }} + - name: Save test/dummy/node_modules to cache + uses: actions/cache@v3 + with: + path: test/dummy/node_modules + key: dummy-app-node-modules-cache-${{ hashFiles('test/dummy/yarn.lock') }} + - uses: ruby/setup-ruby@v1 + with: + bundler: 2.4.9 + ruby-version: ${{ matrix.ruby }} + - run: bundle config set --local path 'test/dummy/vendor/bundle' + - run: ./test/bin/create-fake-js-package-managers ${{ matrix.js_package_manager.installer }} + - name: Save dummy app ruby gems to cache + uses: actions/cache@v3 + with: + path: test/dummy/vendor/bundle + key: dummy-app-gem-cache-${{ hashFiles(format('{0}/gemfiles/{1}.gemfile.lock', github.workspace, matrix.gemfile)) }} + - name: Install Ruby Gems for dummy app + run: bundle lock --add-platform 'x86_64-linux' && bundle check --path=test/dummy/vendor/bundle || bundle _2.4.9_ install --frozen --path=test/dummy/vendor/bundle --jobs=4 --retry=3 + - run: cd test/dummy && yalc add react_ujs && ${{ matrix.js_package_manager.installer }} install + - run: bundle exec rake test + env: + NODE_OPTIONS: --openssl-legacy-provider diff --git a/Appraisals b/Appraisals index 50a89c68..7582ded1 100644 --- a/Appraisals +++ b/Appraisals @@ -20,6 +20,6 @@ appraise 'shakapacker' do gem 'shakapacker', '7.2.0' end -appraise 'connection_pool_2' do - gem 'connection_pool', '~> 2' +appraise 'connection_pool_3' do + gem 'connection_pool', '~> 3' end diff --git a/gemfiles/connection_pool_2.gemfile b/gemfiles/connection_pool_3.gemfile similarity index 75% rename from gemfiles/connection_pool_2.gemfile rename to gemfiles/connection_pool_3.gemfile index e2237f5c..1ef22bba 100644 --- a/gemfiles/connection_pool_2.gemfile +++ b/gemfiles/connection_pool_3.gemfile @@ -2,6 +2,6 @@ source "http://rubygems.org" -gem "connection_pool", "~> 2" +gem "connection_pool", "~> 3" gemspec path: "../" diff --git a/gemfiles/connection_pool_3.gemfile.lock b/gemfiles/connection_pool_3.gemfile.lock new file mode 100644 index 00000000..06f667bf --- /dev/null +++ b/gemfiles/connection_pool_3.gemfile.lock @@ -0,0 +1,278 @@ +PATH + remote: .. + specs: + react-rails (3.2.1) + babel-transpiler (>= 0.7.0) + connection_pool + execjs + railties (>= 3.2) + tilt + +GEM + remote: http://rubygems.org/ + specs: + actioncable (7.0.8.1) + actionpack (= 7.0.8.1) + activesupport (= 7.0.8.1) + nio4r (~> 2.0) + websocket-driver (>= 0.6.1) + actionmailbox (7.0.8.1) + actionpack (= 7.0.8.1) + activejob (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) + mail (>= 2.7.1) + net-imap + net-pop + net-smtp + actionmailer (7.0.8.1) + actionpack (= 7.0.8.1) + actionview (= 7.0.8.1) + activejob (= 7.0.8.1) + activesupport (= 7.0.8.1) + mail (~> 2.5, >= 2.5.4) + net-imap + net-pop + net-smtp + rails-dom-testing (~> 2.0) + actionpack (7.0.8.1) + actionview (= 7.0.8.1) + activesupport (= 7.0.8.1) + rack (~> 2.0, >= 2.2.4) + rack-test (>= 0.6.3) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.0, >= 1.2.0) + actiontext (7.0.8.1) + actionpack (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) + globalid (>= 0.6.0) + nokogiri (>= 1.8.5) + actionview (7.0.8.1) + activesupport (= 7.0.8.1) + builder (~> 3.1) + erubi (~> 1.4) + rails-dom-testing (~> 2.0) + rails-html-sanitizer (~> 1.1, >= 1.2.0) + activejob (7.0.8.1) + activesupport (= 7.0.8.1) + globalid (>= 0.3.6) + activemodel (7.0.8.1) + activesupport (= 7.0.8.1) + activerecord (7.0.8.1) + activemodel (= 7.0.8.1) + activesupport (= 7.0.8.1) + activestorage (7.0.8.1) + actionpack (= 7.0.8.1) + activejob (= 7.0.8.1) + activerecord (= 7.0.8.1) + activesupport (= 7.0.8.1) + marcel (~> 1.0) + mini_mime (>= 1.1.0) + activesupport (7.0.8.1) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + addressable (2.8.0) + public_suffix (>= 2.0.2, < 5.0) + appraisal (2.4.1) + bundler + rake + thor (>= 0.14.0) + babel-source (5.8.35) + babel-transpiler (0.7.0) + babel-source (>= 4.0, < 6) + execjs (~> 2.0) + builder (3.2.4) + byebug (11.0.1) + capybara (3.37.1) + addressable + matrix + mini_mime (>= 0.1.3) + nokogiri (~> 1.8) + rack (>= 1.6.0) + rack-test (>= 0.6.3) + regexp_parser (>= 1.5, < 3.0) + xpath (~> 3.2) + codeclimate-test-reporter (1.0.9) + simplecov (<= 0.13) + coderay (1.1.3) + coffee-rails (5.0.0) + coffee-script (>= 2.2.0) + railties (>= 5.2.0) + coffee-script (2.4.1) + coffee-script-source + execjs + coffee-script-source (1.12.2) + concurrent-ruby (1.1.10) + connection_pool (3.0.2) + crass (1.0.6) + date (3.4.1) + docile (1.1.5) + erubi (1.9.0) + es5-shim-rails (4.0.1) + actionpack (>= 3.1) + railties (>= 3.1) + execjs (2.7.0) + ffi (1.15.5) + formatador (1.1.0) + gem-release (2.2.2) + globalid (1.2.1) + activesupport (>= 6.1) + guard (2.18.0) + formatador (>= 0.2.4) + listen (>= 2.7, < 4.0) + lumberjack (>= 1.0.12, < 2.0) + nenv (~> 0.1) + notiffany (~> 0.0) + pry (>= 0.13.0) + shellany (~> 0.0) + thor (>= 0.18.1) + guard-compat (1.2.1) + guard-minitest (2.4.6) + guard-compat (~> 1.2) + minitest (>= 3.0) + i18n (1.12.0) + concurrent-ruby (~> 1.0) + jbuilder (2.11.5) + actionview (>= 5.0.0) + activesupport (>= 5.0.0) + json (2.9.1) + listen (3.0.8) + rb-fsevent (~> 0.9, >= 0.9.4) + rb-inotify (~> 0.9, >= 0.9.7) + loofah (2.19.1) + crass (~> 1.0.2) + nokogiri (>= 1.5.9) + lumberjack (1.2.8) + mail (2.8.1) + mini_mime (>= 0.1.1) + net-imap + net-pop + net-smtp + marcel (1.0.4) + matrix (0.4.2) + method_source (1.0.0) + mini_mime (1.1.2) + minitest (5.17.0) + minitest-retry (0.2.2) + minitest (>= 5.0) + nenv (0.3.0) + net-imap (0.4.11) + date + net-protocol + net-pop (0.1.2) + net-protocol + net-protocol (0.2.2) + timeout + net-smtp (0.5.0) + net-protocol + nio4r (2.7.3) + nokogiri (1.18.10-x86_64-linux-gnu) + racc (~> 1.4) + notiffany (0.1.3) + nenv (~> 0.1) + shellany (~> 0.0) + package_json (0.1.0) + pry (0.14.2) + coderay (~> 1.1) + method_source (~> 1.0) + pry-byebug (3.8.0) + byebug (~> 11.0) + pry (~> 0.10) + public_suffix (4.0.6) + racc (1.6.2) + rack (2.2.6.4) + rack-test (2.0.2) + rack (>= 1.3) + rails (7.0.8.1) + actioncable (= 7.0.8.1) + actionmailbox (= 7.0.8.1) + actionmailer (= 7.0.8.1) + actionpack (= 7.0.8.1) + actiontext (= 7.0.8.1) + actionview (= 7.0.8.1) + activejob (= 7.0.8.1) + activemodel (= 7.0.8.1) + activerecord (= 7.0.8.1) + activestorage (= 7.0.8.1) + activesupport (= 7.0.8.1) + bundler (>= 1.15.0) + railties (= 7.0.8.1) + rails-dom-testing (2.0.3) + activesupport (>= 4.2.0) + nokogiri (>= 1.6) + rails-html-sanitizer (1.4.4) + loofah (~> 2.19, >= 2.19.1) + railties (7.0.8.1) + actionpack (= 7.0.8.1) + activesupport (= 7.0.8.1) + method_source + rake (>= 12.2) + thor (~> 1.0) + zeitwerk (~> 2.5) + rake (13.0.1) + rb-fsevent (0.11.2) + rb-inotify (0.10.1) + ffi (~> 1.0) + regexp_parser (2.6.0) + rexml (3.2.5) + rubyzip (2.3.2) + selenium-webdriver (4.9.0) + rexml (~> 3.2, >= 3.2.5) + rubyzip (>= 1.2.2, < 3.0) + websocket (~> 1.0) + shellany (0.0.1) + simplecov (0.13.0) + docile (~> 1.1.0) + json (>= 1.8, < 3) + simplecov-html (~> 0.10.0) + simplecov-html (0.10.2) + test-unit (2.5.5) + thor (1.2.1) + tilt (2.1.0) + timeout (0.4.3) + turbo-rails (2.0.5) + actionpack (>= 6.0.0) + activejob (>= 6.0.0) + railties (>= 6.0.0) + tzinfo (2.0.6) + concurrent-ruby (~> 1.0) + websocket (1.2.9) + websocket-driver (0.7.6) + websocket-extensions (>= 0.1.0) + websocket-extensions (0.1.5) + xpath (3.2.0) + nokogiri (~> 1.8) + zeitwerk (2.6.6) + +PLATFORMS + x86_64-linux + +DEPENDENCIES + appraisal + bundler (= 2.4.9) + capybara + codeclimate-test-reporter + coffee-rails + connection_pool (~> 3) + es5-shim-rails (>= 2.0.5) + gem-release + guard + guard-minitest + jbuilder + listen (~> 3.0.0) + minitest-retry + package_json + pry-byebug + rails (~> 7.0.7, >= 7.0.7.2) + react-rails! + selenium-webdriver + test-unit (~> 2.5) + turbo-rails + +BUNDLED WITH + 2.4.9 From 65b2157e4fee52931091e83e3ef06f3a6fec3017 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Sat, 6 Dec 2025 21:41:12 +0000 Subject: [PATCH 3/5] fix: support `connection_pool` v3 --- lib/react/server_rendering.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/react/server_rendering.rb b/lib/react/server_rendering.rb index 3abe72cf..053f0357 100644 --- a/lib/react/server_rendering.rb +++ b/lib/react/server_rendering.rb @@ -16,7 +16,13 @@ module ServerRendering # @return [void] def self.reset_pool options = { size: pool_size, timeout: pool_timeout } - @pool = ConnectionPool.new(options) { renderer.new(renderer_options) } + + # ConnectionPool v3+ uses keyword arguments rather than positional + @pool = if ConnectionPool::VERSION[0] <= "2" + ConnectionPool.new(options) { renderer.new(renderer_options) } + else + ConnectionPool.new(**options) { renderer.new(renderer_options) } + end end # Check a renderer out of the pool and use it to render the component. From 832d55561ae9e8252650ea8aa201fcb879267389 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Sat, 6 Dec 2025 21:52:52 +0000 Subject: [PATCH 4/5] docs: add changelog entry --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2e6a5af9..c887c808 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,10 @@ _Please add entries here for your pull requests that have not yet been released. - Support for Propshaft server rendering. [PR 1345](https://github.com/reactjs/react-rails/pull/1345) by [elektronaut](https://github.com/elektronaut) +#### Fixed + +- Support `connection_pool` v3 [PR 1367](https://github.com/reactjs/react-rails/pull/1367) by [G-Rath](https://github.com/G-Rath). + ## [3.2.1] - 2024-05-16 #### Fixed From e9348c68018c0c1c667cc65b3eeee3b2db7f05e6 Mon Sep 17 00:00:00 2001 From: Gareth Jones <3151613+G-Rath@users.noreply.github.com> Date: Tue, 9 Dec 2025 07:18:00 +1300 Subject: [PATCH 5/5] refactor simplify fix --- lib/react/server_rendering.rb | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/react/server_rendering.rb b/lib/react/server_rendering.rb index 053f0357..0d87c26a 100644 --- a/lib/react/server_rendering.rb +++ b/lib/react/server_rendering.rb @@ -16,13 +16,7 @@ module ServerRendering # @return [void] def self.reset_pool options = { size: pool_size, timeout: pool_timeout } - - # ConnectionPool v3+ uses keyword arguments rather than positional - @pool = if ConnectionPool::VERSION[0] <= "2" - ConnectionPool.new(options) { renderer.new(renderer_options) } - else - ConnectionPool.new(**options) { renderer.new(renderer_options) } - end + @pool = ConnectionPool.new(**options) { renderer.new(renderer_options) } end # Check a renderer out of the pool and use it to render the component.