retry.Retryable(): treat ENOENT (AF_UNIX) like ECONNREFUSED, i.e. also retry

During connect(2) we may get ECONNREFUSED between server's bind(2) and
listen(2), but the most downtime between boot and service start the socket
won't exist, yet. I.e. ENOENT is the de facto ECONNREFUSED of *nix sockets.
This commit is contained in:
Alexander A. Klimov 2023-06-05 11:21:45 +02:00
parent 4ed4db3ab6
commit a3c1007d47

View file

@ -114,9 +114,9 @@ func Retryable(err error) bool {
// which is not considered temporary or timed out by Go.
err = opError.Err
}
if errors.Is(err, syscall.ECONNREFUSED) {
if errors.Is(err, syscall.ECONNREFUSED) || errors.Is(err, syscall.ENOENT) {
// syscall errors provide Temporary() and Timeout(),
// which do not include ECONNREFUSED, so we check this ourselves.
// which do not include ECONNREFUSED or ENOENT, so we check these ourselves.
return true
}
if errors.Is(err, syscall.ECONNRESET) {