Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/jobs/action_push_native/notification_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def exponential_backoff_delay(executions)

with_options retry_options do
retry_on TimeoutError, wait: 1.minute
retry_on ConnectionError, HTTPX::PoolTimeoutError, attempts: 20
retry_on ConnectionError, ConnectionPoolTimeoutError, attempts: 20

# Altough unexpected, these are short-lived errors that can be retried most of the times.
retry_on ForbiddenError, BadRequestError
Expand Down
1 change: 1 addition & 0 deletions lib/action_push_native/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
module ActionPushNative
class TimeoutError < StandardError; end
class ConnectionError < StandardError; end
class ConnectionPoolTimeoutError < StandardError; end

class BadRequestError < StandardError; end
class ForbiddenError < StandardError; end
Expand Down
2 changes: 1 addition & 1 deletion lib/action_push_native/service/network_error_handling.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module ActionPushNative::Service::NetworkErrorHandling
def handle_network_error(error)
case error
when HTTPX::PoolTimeoutError
raise error
raise ActionPushNative::ConnectionPoolTimeoutError, error.message
when Errno::ETIMEDOUT, HTTPX::TimeoutError
raise ActionPushNative::TimeoutError, error.message
when Errno::ECONNRESET, Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::EHOSTUNREACH,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ shared:
topic: your.bundle.identifier

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

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

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

# Change the request timeout (default: 15).
Expand Down
4 changes: 2 additions & 2 deletions test/dummy/config/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ shared:
topic: your.bundle.identifier

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

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

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

# Firebase project_id
Expand Down
3 changes: 2 additions & 1 deletion test/lib/action_push_native/service/apns_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,10 @@ class ApnsTest < ActiveSupport::TestCase
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
error = assert_raises ActionPushNative::ConnectionPoolTimeoutError do
@apns.push(@notification)
end
assert_equal "Timed out after 5 seconds while waiting for a connection", error.message
end

test "push apns payload can be overridden" do
Expand Down