Skip to content

Commit

Permalink
fix(storage): retry io.ErrUnexpectedEOF (#3957)
Browse files Browse the repository at this point in the history
This error can be caused by network flakiness. We already retry
it in the apiary client logic for uploads, so we should retry
here as well.
  • Loading branch information
tritone committed Apr 19, 2021
1 parent 98a5598 commit f6590cd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions storage/go110.go
Expand Up @@ -17,13 +17,17 @@
package storage

import (
"io"
"net/url"
"strings"

"google.golang.org/api/googleapi"
)

func shouldRetry(err error) bool {
if err == io.ErrUnexpectedEOF {
return true
}
switch e := err.(type) {
case *googleapi.Error:
// Retry on 429 and 5xx, according to
Expand Down
2 changes: 2 additions & 0 deletions storage/go110_test.go
Expand Up @@ -19,6 +19,7 @@ package storage
import (
"context"
"errors"
"io"
"net/url"
"testing"

Expand All @@ -43,6 +44,7 @@ func TestInvoke(t *testing.T) {
{2, &googleapi.Error{Code: 518}, nil},
{2, &googleapi.Error{Code: 599}, &googleapi.Error{Code: 428}},
{1, &url.Error{Op: "blah", URL: "blah", Err: errors.New("connection refused")}, nil},
{1, io.ErrUnexpectedEOF, nil},
} {
counter := 0
call := func() error {
Expand Down

0 comments on commit f6590cd

Please sign in to comment.