Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mark recoverability of DNS errors correctly #1088

Merged
merged 1 commit into from
Aug 2, 2023
Merged
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
13 changes: 10 additions & 3 deletions src/clientlayers/RetryRequest.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down