Skip to content

Commit 77bc57e

Browse files
committed
martian: fix and simplify isCloseable
Notice that it used to return neterr.Timeout error as closable. This was wrong as we want to retry on any timeout error. This is why handle loop checks for maxConsecutiveErrors.
1 parent 67b392c commit 77bc57e

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

internal/martian/errors.go

+7-9
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,16 @@ func isClosedConnError(err error) bool {
8282

8383
// isCloseable reports whether err is an error that indicates the client connection should be closed.
8484
func isCloseable(err error) bool {
85-
if errors.Is(err, io.EOF) ||
86-
errors.Is(err, io.ErrUnexpectedEOF) ||
87-
errors.Is(err, io.ErrClosedPipe) {
88-
return true
85+
if err == nil {
86+
return false
8987
}
9088

9189
var neterr net.Error
92-
if ok := errors.As(err, &neterr); ok && neterr.Timeout() {
93-
return true
94-
}
95-
96-
return strings.Contains(err.Error(), "tls:")
90+
return errors.Is(err, io.EOF) ||
91+
errors.Is(err, io.ErrUnexpectedEOF) ||
92+
errors.Is(err, io.ErrClosedPipe) ||
93+
(errors.As(err, &neterr) && !neterr.Timeout()) ||
94+
strings.Contains(err.Error(), "tls:")
9795
}
9896

9997
type ErrorStatus struct { //nolint:errname // ErrorStatus is a type name not a variable.

0 commit comments

Comments
 (0)