Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(internal/gensuport): don't prematurely close timers.
Browse files Browse the repository at this point in the history
quitAfterTimer should only be closed when function breaks or
returns as it is created outside of the for loop. Tested with
local replacing and fixes failing TestIndefiniteRetries test with
the patch.

Fixes: googleapis/google-cloud-go#7410
codyoss committed Feb 13, 2023

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 3fb5b61 commit 3c99d4c
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions internal/gensupport/resumable.go
Original file line number Diff line number Diff line change
@@ -209,7 +209,6 @@ func (rx *ResumableUpload) Upload(ctx context.Context) (resp *http.Response, err
}
return prepareReturn(resp, err)
case <-pauseTimer.C:
quitAfterTimer.Stop()
case <-quitAfterTimer.C:
pauseTimer.Stop()
return prepareReturn(resp, err)
@@ -231,7 +230,6 @@ func (rx *ResumableUpload) Upload(ctx context.Context) (resp *http.Response, err
case <-quitAfterTimer.C:
return prepareReturn(resp, err)
default:
quitAfterTimer.Stop()
}

resp, err = rx.transferChunk(ctx)
@@ -243,6 +241,7 @@ func (rx *ResumableUpload) Upload(ctx context.Context) (resp *http.Response, err

// Check if we should retry the request.
if !errorFunc(status, err) {
quitAfterTimer.Stop()
break
}

0 comments on commit 3c99d4c

Please sign in to comment.