mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-07 00:05:02 -04:00
reconnectable errors: include HTTP/2 parser errors and opnessl errors
This commit is contained in:
parent
540430c00e
commit
d5483a4264
@ -18,18 +18,6 @@ module HTTPX
|
|||||||
# https://gitlab.com/os85/httpx/wikis/Persistent
|
# https://gitlab.com/os85/httpx/wikis/Persistent
|
||||||
#
|
#
|
||||||
module 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)
|
def self.load_dependencies(klass)
|
||||||
max_retries = if klass.default_options.respond_to?(:max_retries)
|
max_retries = if klass.default_options.respond_to?(:max_retries)
|
||||||
[klass.default_options.max_retries, 1].max
|
[klass.default_options.max_retries, 1].max
|
||||||
@ -56,7 +44,7 @@ module HTTPX
|
|||||||
|
|
||||||
error = response.error
|
error = response.error
|
||||||
|
|
||||||
RECONNECTABLE_ERRORS.any? { |klass| error.is_a?(klass) }
|
Retries::RECONNECTABLE_ERRORS.any? { |klass| error.is_a?(klass) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -17,7 +17,9 @@ module HTTPX
|
|||||||
# TODO: pass max_retries in a configure/load block
|
# TODO: pass max_retries in a configure/load block
|
||||||
|
|
||||||
IDEMPOTENT_METHODS = %w[GET OPTIONS HEAD PUT DELETE].freeze
|
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,
|
IOError,
|
||||||
EOFError,
|
EOFError,
|
||||||
Errno::ECONNRESET,
|
Errno::ECONNRESET,
|
||||||
@ -25,12 +27,15 @@ module HTTPX
|
|||||||
Errno::EPIPE,
|
Errno::EPIPE,
|
||||||
Errno::EINVAL,
|
Errno::EINVAL,
|
||||||
Errno::ETIMEDOUT,
|
Errno::ETIMEDOUT,
|
||||||
Parser::Error,
|
|
||||||
TLSError,
|
|
||||||
TimeoutError,
|
|
||||||
ConnectionError,
|
ConnectionError,
|
||||||
Connection::HTTP2::GoawayError,
|
TLSError,
|
||||||
|
Connection::HTTP2::Error,
|
||||||
].freeze
|
].freeze
|
||||||
|
|
||||||
|
RETRYABLE_ERRORS = (RECONNECTABLE_ERRORS + [
|
||||||
|
Parser::Error,
|
||||||
|
TimeoutError,
|
||||||
|
]).freeze
|
||||||
DEFAULT_JITTER = ->(interval) { interval * ((rand + 1) * 0.5) }
|
DEFAULT_JITTER = ->(interval) { interval * ((rand + 1) * 0.5) }
|
||||||
|
|
||||||
if ENV.key?("HTTPX_NO_JITTER")
|
if ENV.key?("HTTPX_NO_JITTER")
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
module HTTPX
|
module HTTPX
|
||||||
module Plugins
|
module Plugins
|
||||||
module Persistent
|
module Persistent
|
||||||
RECONNECTABLE_ERRORS: Array[singleton(StandardError)]
|
|
||||||
|
|
||||||
def self.load_dependencies: (singleton(Session)) -> void
|
def self.load_dependencies: (singleton(Session)) -> void
|
||||||
|
|
||||||
def self.extra_options: (Options) -> (Options)
|
def self.extra_options: (Options) -> (Options)
|
||||||
|
@ -3,6 +3,7 @@ module HTTPX
|
|||||||
module Retries
|
module Retries
|
||||||
MAX_RETRIES: Integer
|
MAX_RETRIES: Integer
|
||||||
IDEMPOTENT_METHODS: Array[String]
|
IDEMPOTENT_METHODS: Array[String]
|
||||||
|
RECONNECTABLE_ERRORS: Array[singleton(StandardError)]
|
||||||
RETRYABLE_ERRORS: Array[singleton(StandardError)]
|
RETRYABLE_ERRORS: Array[singleton(StandardError)]
|
||||||
DEFAULT_JITTER: ^(Numeric) -> Numeric
|
DEFAULT_JITTER: ^(Numeric) -> Numeric
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user