Skip to content

Commit

Permalink
feat(internal/gensupport): add 408 to default retry (#1397)
Browse files Browse the repository at this point in the history
  • Loading branch information
BrennaEpp committed Jan 18, 2022
1 parent 2f7c9e0 commit 576ebbf
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion google-api-go-generator/gen.go
Expand Up @@ -2001,7 +2001,7 @@ func (meth *Method) generateCode() {
"which errors are considered retryable. By default, exponetial backoff will be" +
"applied using gax defaults, and the following errors are retried:" +
"\n\n" +
"- HTTP responses with codes 429, 502, 503, and 504." +
"- HTTP responses with codes 408, 429, 502, 503, and 504." +
"\n\n" +
"- Transient network errors such as connection reset and io.ErrUnexpectedEOF." +
"\n\n" +
Expand Down
6 changes: 5 additions & 1 deletion internal/gensupport/retry.go
Expand Up @@ -36,6 +36,10 @@ const (
// should be retried.
// https://cloud.google.com/storage/docs/json_api/v1/status-codes#standardcodes
statusTooManyRequests = 429

// statusRequestTimeout is returned by the storage API if the
// upload connection was broken. The request should be retried.
statusRequestTimeout = 408
)

// shouldRetry indicates whether an error is retryable for the purposes of this
Expand All @@ -46,7 +50,7 @@ func shouldRetry(status int, err error) bool {
if 500 <= status && status <= 599 {
return true
}
if status == statusTooManyRequests {
if status == statusTooManyRequests || status == statusRequestTimeout {
return true
}
if err == io.ErrUnexpectedEOF {
Expand Down
2 changes: 1 addition & 1 deletion storage/v1/storage-gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 576ebbf

Please sign in to comment.