Skip to content

Commit cb24a27

Browse files
committed
Wrap PoolTimeoutErrors with ActionPushNative::ConnectionPoolTimeoutError
1 parent 6a28828 commit cb24a27

File tree

6 files changed

+9
-7
lines changed

6 files changed

+9
-7
lines changed

app/jobs/action_push_native/notification_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def exponential_backoff_delay(executions)
4040

4141
with_options retry_options do
4242
retry_on TimeoutError, wait: 1.minute
43-
retry_on ConnectionError, HTTPX::PoolTimeoutError, attempts: 20
43+
retry_on ConnectionError, ConnectionPoolTimeoutError, attempts: 20
4444

4545
# Altough unexpected, these are short-lived errors that can be retried most of the times.
4646
retry_on ForbiddenError, BadRequestError

lib/action_push_native/errors.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
module ActionPushNative
44
class TimeoutError < StandardError; end
55
class ConnectionError < StandardError; end
6+
class ConnectionPoolTimeoutError < StandardError; end
67

78
class BadRequestError < StandardError; end
89
class ForbiddenError < StandardError; end

lib/action_push_native/service/network_error_handling.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module ActionPushNative::Service::NetworkErrorHandling
44
def handle_network_error(error)
55
case error
66
when HTTPX::PoolTimeoutError
7-
raise error
7+
raise ActionPushNative::ConnectionPoolTimeoutError, error.message
88
when Errno::ETIMEDOUT, HTTPX::TimeoutError
99
raise ActionPushNative::TimeoutError, error.message
1010
when Errno::ECONNRESET, Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::EHOSTUNREACH,

lib/generators/action_push_native/install/templates/config/push.yml.tt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ shared:
1111
topic: your.bundle.identifier
1212

1313
# Set this to the number of threads used to process notifications (default: 5).
14-
# When the pool size is too small a HTTPX::PoolTimeoutError error will be raised.
14+
# When the pool size is too small a ConnectionPoolTimeoutError will be raised.
1515
# connection_pool_size: 5
1616

1717
# Change the request timeout (default: 30).
@@ -33,7 +33,7 @@ shared:
3333
project_id: your_project_id
3434

3535
# Set this to the number of threads used to process notifications (default: 5).
36-
# When the pool size is too small a HTTPX::PoolTimeoutError error will be raised.
36+
# When the pool size is too small a ConnectionPoolTimeoutError will be raised.
3737
# connection_pool_size: 5
3838

3939
# Change the request timeout (default: 15).

test/dummy/config/push.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ shared:
1111
topic: your.bundle.identifier
1212

1313
# Set this to the number of threads used to process notifications (default: 5).
14-
# When the pool size is too small a HTTPX::PoolTimeoutError error will be raised.
14+
# When the pool size is too small a ConnectionPoolTimeoutError will be raised.
1515
# connection_pool_size: 5
1616

1717
# Change the request timeout (default: 30).
@@ -30,7 +30,7 @@ shared:
3030
encryption_key: <%= Rails.application.credentials.dig(:action_push_native, :fcm, :encryption_key)&.dump %>
3131

3232
# Set this to the number of threads used to process notifications (default: 5).
33-
# When the pool size is too small a HTTPX::PoolTimeoutError error will be raised.
33+
# When the pool size is too small a ConnectionPoolTimeoutError will be raised.
3434
# connection_pool_size: 5
3535

3636
# Firebase project_id

test/lib/action_push_native/service/apns_test.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,10 @@ class ApnsTest < ActiveSupport::TestCase
8686
stub_request(:post, "https://api.push.apple.com/3/device/123").
8787
to_raise(HTTPX::PoolTimeoutError.new(5, "Timed out after 5 seconds while waiting for a connection"))
8888

89-
assert_raises HTTPX::PoolTimeoutError do
89+
error = assert_raises ActionPushNative::ConnectionPoolTimeoutError do
9090
@apns.push(@notification)
9191
end
92+
assert_equal "Timed out after 5 seconds while waiting for a connection", error.message
9293
end
9394

9495
test "push apns payload can be overridden" do

0 commit comments

Comments
 (0)