From 9c4279b8505b9d05275c32a2995c499005894c66 Mon Sep 17 00:00:00 2001 From: Jacopo Date: Fri, 26 Sep 2025 16:01:11 +0200 Subject: [PATCH] Correctly catch and re-raise HTTPX PoolTimeoutErrors --- lib/action_push_native/service/network_error_handling.rb | 2 ++ test/lib/action_push_native/service/apns_test.rb | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/lib/action_push_native/service/network_error_handling.rb b/lib/action_push_native/service/network_error_handling.rb index b36b306..b2552fa 100644 --- a/lib/action_push_native/service/network_error_handling.rb +++ b/lib/action_push_native/service/network_error_handling.rb @@ -3,6 +3,8 @@ module ActionPushNative::Service::NetworkErrorHandling def handle_network_error(error) case error + when HTTPX::PoolTimeoutError + raise error when Errno::ETIMEDOUT, HTTPX::TimeoutError raise ActionPushNative::TimeoutError, error.message when Errno::ECONNRESET, Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::EHOSTUNREACH, diff --git a/test/lib/action_push_native/service/apns_test.rb b/test/lib/action_push_native/service/apns_test.rb index 2d9a2fb..9615f93 100644 --- a/test/lib/action_push_native/service/apns_test.rb +++ b/test/lib/action_push_native/service/apns_test.rb @@ -82,6 +82,13 @@ class ApnsTest < ActiveSupport::TestCase assert_raises ActionPushNative::ConnectionError do @apns.push(@notification) end + + stub_request(:post, "https://api.push.apple.com/3/device/123"). + to_raise(HTTPX::PoolTimeoutError.new(5, "Timed out after 5 seconds while waiting for a connection")) + + assert_raises HTTPX::PoolTimeoutError do + @apns.push(@notification) + end end test "push apns payload can be overridden" do