Skip to content

Commit

Permalink
retry net.ErrClosed by default (#2949)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucix-aws authored Jan 8, 2025
1 parent 19d2a28 commit ebb7c02
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .changelog/b2213048b0dd4619bd611e41eb07bcb0.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"id": "b2213048-b0dd-4619-bd61-1e41eb07bcb0",
"type": "bugfix",
"description": "Retry transient net.ErrClosed errors by default.",
"modules": [
"."
]
}
6 changes: 6 additions & 0 deletions aws/retry/retryable_error.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ func (r RetryableConnectionError) IsErrorRetryable(err error) aws.Ternary {
case errors.As(err, &conErr) && conErr.ConnectionError():
retryable = true

case strings.Contains(err.Error(), "use of closed network connection"):
fallthrough
case strings.Contains(err.Error(), "connection reset"):
// The errors "connection reset" and "use of closed network connection"
// are effectively the same. It appears to be the difference between
// sync and async read of TCP RST in the stdlib's net.Conn read loop.
// see #2737
retryable = true

case errors.As(err, &urlErr):
Expand Down
4 changes: 4 additions & 0 deletions aws/retry/retryable_error_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ func TestRetryConnectionErrors(t *testing.T) {
Err: fmt.Errorf("some error %w", mockTimeoutError{b: true}),
},
},
"net.ErrClosed": {
Retryable: aws.TrueTernary,
Err: net.ErrClosed,
},
}

for name, c := range cases {
Expand Down

0 comments on commit ebb7c02

Please sign in to comment.