reconnectable errors: include HTTP/2 parser errors and opnessl errors

This commit is contained in:
HoneyryderChuck 2025-05-03 00:41:26 +01:00
parent 540430c00e
commit d5483a4264
4 changed files with 12 additions and 20 deletions

View File

@ -18,18 +18,6 @@ module HTTPX
# https://gitlab.com/os85/httpx/wikis/Persistent
#
module Persistent
# subset of retryable errors which are safe to retry when reconnecting
RECONNECTABLE_ERRORS = [
IOError,
EOFError,
Errno::ECONNRESET,
Errno::ECONNABORTED,
Errno::EPIPE,
Errno::EINVAL,
Errno::ETIMEDOUT,
ConnectionError,
].freeze
def self.load_dependencies(klass)
max_retries = if klass.default_options.respond_to?(:max_retries)
[klass.default_options.max_retries, 1].max
@ -56,7 +44,7 @@ module HTTPX
error = response.error
RECONNECTABLE_ERRORS.any? { |klass| error.is_a?(klass) }
Retries::RECONNECTABLE_ERRORS.any? { |klass| error.is_a?(klass) }
end
end

View File

@ -17,7 +17,9 @@ module HTTPX
# TODO: pass max_retries in a configure/load block
IDEMPOTENT_METHODS = %w[GET OPTIONS HEAD PUT DELETE].freeze
RETRYABLE_ERRORS = [
# subset of retryable errors which are safe to retry when reconnecting
RECONNECTABLE_ERRORS = [
IOError,
EOFError,
Errno::ECONNRESET,
@ -25,12 +27,15 @@ module HTTPX
Errno::EPIPE,
Errno::EINVAL,
Errno::ETIMEDOUT,
Parser::Error,
TLSError,
TimeoutError,
ConnectionError,
Connection::HTTP2::GoawayError,
TLSError,
Connection::HTTP2::Error,
].freeze
RETRYABLE_ERRORS = (RECONNECTABLE_ERRORS + [
Parser::Error,
TimeoutError,
]).freeze
DEFAULT_JITTER = ->(interval) { interval * ((rand + 1) * 0.5) }
if ENV.key?("HTTPX_NO_JITTER")

View File

@ -1,8 +1,6 @@
module HTTPX
module Plugins
module Persistent
RECONNECTABLE_ERRORS: Array[singleton(StandardError)]
def self.load_dependencies: (singleton(Session)) -> void
def self.extra_options: (Options) -> (Options)

View File

@ -3,6 +3,7 @@ module HTTPX
module Retries
MAX_RETRIES: Integer
IDEMPOTENT_METHODS: Array[String]
RECONNECTABLE_ERRORS: Array[singleton(StandardError)]
RETRYABLE_ERRORS: Array[singleton(StandardError)]
DEFAULT_JITTER: ^(Numeric) -> Numeric