From f27639ad007e3a4729925e4231ec8b10626533a0 Mon Sep 17 00:00:00 2001 From: Yuichi Sato <949545+yasaichi@users.noreply.github.com> Date: Thu, 3 Sep 2026 13:25:07 +0100 Subject: [PATCH] Allow connection_pool 3.x The existing 2.x-only constraint excludes a compatible major version even though the SDK's current API usage remains compatible with 3.x. Raise the minimum to the first release that can discard broken connections so the declared dependency also matches the current error path. --- statsig.gemspec | 2 +- test/test_network.rb | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/statsig.gemspec b/statsig.gemspec index 1bdd3bb..a399a65 100644 --- a/statsig.gemspec +++ b/statsig.gemspec @@ -29,7 +29,7 @@ Gem::Specification.new do |s| s.add_development_dependency 'simplecov-cobertura', '~> 2.1' s.add_runtime_dependency 'user_agent_parser', '~> 2.18.0' s.add_runtime_dependency 'http', '>= 4.4', '< 6.0' - s.add_runtime_dependency 'connection_pool', '~> 2.4', '>= 2.4.1' + s.add_runtime_dependency 'connection_pool', '>= 2.5.4', '< 4.0' s.add_runtime_dependency 'ip3country', '~> 0.2.1' s.add_runtime_dependency 'concurrent-ruby', '~> 1.1' s.add_runtime_dependency 'zlib', '>= 3.1', '< 4.0' diff --git a/test/test_network.rb b/test/test_network.rb index 3bc8b07..edd5af6 100644 --- a/test/test_network.rb +++ b/test/test_network.rb @@ -182,6 +182,28 @@ def test_retry_until_out_of_retries assert(!e.nil?) end + def test_discards_failed_connection_without_masking_error + connection_error = IOError.new('broken connection') + failed_builder = FakeHTTPBuilder.new { raise connection_error } + builders = [failed_builder, FakeHTTPBuilder.new { FakeHTTPResponse.new }] + + HTTP.stub(:use, ->(_) { builders.shift }) do + net = Statsig::Network.new('secret-abc', StatsigOptions.new(local_mode: false)) + failed_response, error = net.get('https://statsigapi.net/health') + + assert_nil(failed_response) + assert_same(connection_error, error) + assert(failed_builder.clients['https://statsigapi.net'].closed) + + response, error = net.get('https://statsigapi.net/health') + + assert_nil(error) + assert(response.status.success?) + ensure + net&.shutdown + end + end + def test_reuses_persistent_clients_per_origin_and_drains_response_bodies builder = FakeHTTPBuilder.new { FakeHTTPResponse.new } options = StatsigOptions.new(local_mode: false, network_timeout: 2)