diff --git a/src/clientlayers/RetryRequest.jl b/src/clientlayers/RetryRequest.jl index 3e8be53c9..0a400851e 100644 --- a/src/clientlayers/RetryRequest.jl +++ b/src/clientlayers/RetryRequest.jl @@ -17,7 +17,7 @@ increasing delay is introduced between attempts to avoid exacerbating network congestion. By default, requests that have a retryable body, where the request wasn't written -or is idempotent will be retries. If the request is made and a response is received +or is idempotent will be retried. If the request is made and a response is received with a status code of 403, 408, 409, 429, or 5xx, the request will be retried. `retries` controls the # of total retries that will be attempted. @@ -76,10 +76,17 @@ function retrylayer(handler) end end -const EAI_AGAIN = 2 isrecoverable(ex) = true isrecoverable(ex::CapturedException) = isrecoverable(ex.ex) -isrecoverable(ex::ConnectError) = ex.error isa Sockets.DNSError && ex.error.code == EAI_AGAIN ? false : true +# Treat all DNS errors except `EAI_AGAIN`` as non-recoverable +# Ref: https://github.com/JuliaLang/julia/blob/ec8df3da3597d0acd503ff85ac84a5f8f73f625b/stdlib/Sockets/src/addrinfo.jl#L108-L112 +function isrecoverable(ex::ConnectError) + if ex.error isa Sockets.DNSError + return (ex.error.code == Base.UV_EAI_AGAIN) ? true : false + else + return true + end +end isrecoverable(ex::StatusError) = retryable(ex.status) function _retry_check(s, ex, req, check)