From 9baab2f5bcc0c5c35cc245d93265d232a451dde4 Mon Sep 17 00:00:00 2001 From: 40handz Date: Wed, 1 Apr 2026 12:27:03 -0400 Subject: [PATCH 1/4] Reset HTTP client connection after unknown error responses --- lib/pusher/request.rb | 5 ++++- spec/client_spec.rb | 44 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 1 deletion(-) diff --git a/lib/pusher/request.rb b/lib/pusher/request.rb index baa2ae4..16adea2 100644 --- a/lib/pusher/request.rb +++ b/lib/pusher/request.rb @@ -36,8 +36,11 @@ def send_sync end body = response.body ? response.body.chomp : nil + code = response.code.to_i - return handle_response(response.code.to_i, body) + http.reset_all unless [200, 202, 400, 401, 403, 404, 407, 413].include?(code) + + return handle_response(code, body) end def send_async diff --git a/spec/client_spec.rb b/spec/client_spec.rb index 474f83e..d22e211 100644 --- a/spec/client_spec.rb +++ b/spec/client_spec.rb @@ -262,6 +262,50 @@ :occupied => false, }) end + + it "should not reset the http client connection after a 400 error" do + api_path = %r{/apps/20/channels/mychannel} + stub_request(:get, api_path).to_return({ :status => 400, :body => "Bad request" }) + + http_client = @client.sync_http_client + expect(http_client).not_to receive(:reset_all) + + expect { @client.channel_info('mychannel') }.to raise_error(Pusher::Error) + end + + it "should reset the http client connection after an unknown error status" do + api_path = %r{/apps/20/channels/mychannel} + stub_request(:get, api_path).to_return({ :status => 500, :body => "Server error" }) + + http_client = @client.sync_http_client + expect(http_client).to receive(:reset_all).once + + expect { @client.channel_info('mychannel') }.to raise_error(Pusher::Error) + end + + it "should succeed on a subsequent request after an unknown error status" do + api_path = %r{/apps/20/channels/mychannel} + stub_request(:get, api_path) + .to_return({ :status => 500, :body => "Server error" }) + .then + .to_return({ :status => 200, :body => MultiJson.encode({ 'occupied' => false }) }) + + expect { @client.channel_info('mychannel') }.to raise_error(Pusher::Error) + expect(@client.channel_info('mychannel')).to eq({ :occupied => false }) + end + + it "should not reset the http client connection after a successful request" do + api_path = %r{/apps/20/channels/mychannel} + stub_request(:get, api_path).to_return({ + :status => 200, + :body => MultiJson.encode({ 'occupied' => false }) + }) + + http_client = @client.sync_http_client + expect(http_client).not_to receive(:reset_all) + + @client.channel_info('mychannel') + end end describe '#channel_users' do From 2a2f96f0d89d4c93bea1515cf9560d179a1689ff Mon Sep 17 00:00:00 2001 From: 40handz Date: Wed, 1 Apr 2026 12:35:13 -0400 Subject: [PATCH 2/4] Bump version to 2.0.6 --- CHANGELOG.md | 4 ++++ lib/pusher/version.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4efaead..ca20bf6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 2.0.6 + +* [FIXED] Reset HTTP client connection after unknown error responses to prevent subsequent requests from failing. + ## 2.0.5 * [FIXED] Fix webhook content_type parsing for Rails 7.1+ using media_type diff --git a/lib/pusher/version.rb b/lib/pusher/version.rb index 9e04002..18c19ad 100644 --- a/lib/pusher/version.rb +++ b/lib/pusher/version.rb @@ -1,3 +1,3 @@ module Pusher - VERSION = '2.0.5' + VERSION = '2.0.6' end From 4af207a8213fad57922763d442ec1f3368289ad9 Mon Sep 17 00:00:00 2001 From: 40handz Date: Wed, 1 Apr 2026 12:38:15 -0400 Subject: [PATCH 3/4] Revert manual version bump, let CI handle release --- CHANGELOG.md | 4 ---- lib/pusher/version.rb | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca20bf6..4efaead 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,5 @@ # Changelog -## 2.0.6 - -* [FIXED] Reset HTTP client connection after unknown error responses to prevent subsequent requests from failing. - ## 2.0.5 * [FIXED] Fix webhook content_type parsing for Rails 7.1+ using media_type diff --git a/lib/pusher/version.rb b/lib/pusher/version.rb index 18c19ad..9e04002 100644 --- a/lib/pusher/version.rb +++ b/lib/pusher/version.rb @@ -1,3 +1,3 @@ module Pusher - VERSION = '2.0.6' + VERSION = '2.0.5' end From c602611c4f9958155532834ff1889045aeb6f88d Mon Sep 17 00:00:00 2001 From: Pusher CI Date: Thu, 2 Apr 2026 13:33:08 +0000 Subject: [PATCH 4/4] Bump to version 2.1.0 --- CHANGELOG.md | 4 ++++ lib/pusher/version.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4efaead..6782227 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 2.1.0 + +* [FIXED] Reset HTTP client connection after unknown error responses to prevent subsequent requests from failing. + ## 2.0.5 * [FIXED] Fix webhook content_type parsing for Rails 7.1+ using media_type diff --git a/lib/pusher/version.rb b/lib/pusher/version.rb index 9e04002..c5d31df 100644 --- a/lib/pusher/version.rb +++ b/lib/pusher/version.rb @@ -1,3 +1,3 @@ module Pusher - VERSION = '2.0.5' + VERSION = '2.1.0' end