From a758bc17ee3fcce07913275095bafc512a7e441c Mon Sep 17 00:00:00 2001 From: Chris Cotter Date: Thu, 27 Jun 2024 23:14:46 -0400 Subject: [PATCH] fix(gensupport): wrap chunk upload err for retries (#2657) This makes it easier to debug whether and/or how many retries happened before a failure with a chunk upload. --- internal/gensupport/resumable.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/internal/gensupport/resumable.go b/internal/gensupport/resumable.go index 08e7aacefb6..f828ddb60e6 100644 --- a/internal/gensupport/resumable.go +++ b/internal/gensupport/resumable.go @@ -171,6 +171,10 @@ func (rx *ResumableUpload) Upload(ctx context.Context) (resp *http.Response, err if resp != nil && resp.Body != nil { resp.Body.Close() } + // If there were retries, indicate this in the error message and wrap the final error. + if rx.attempts > 1 { + return nil, fmt.Errorf("chunk upload failed after %d attempts;, final error: %w", rx.attempts, err) + } return nil, err } // This case is very unlikely but possible only if rx.ChunkRetryDeadline is