Skip to content

Commit 6960703

Browse files
Bryan C. Millsgopherbot
Bryan C. Mills
authored andcommitted
http2: log the correct error when retrying in (*Transport).RoundTripOpt
On the shouldRetryRequest path, err is invariantly nil, and therefore meaningless to log with vlogf. Instead, log the original error returned by the call to cc.RoundTrip. For golang/go#59155. Change-Id: I82c00a6033d0e92c28a5ccf60a87eec1c8b41886 Reviewed-on: https://go-review.googlesource.com/c/net/+/477876 TryBot-Result: Gopher Robot <[email protected]> Run-TryBot: Bryan Mills <[email protected]> Auto-Submit: Bryan Mills <[email protected]> Reviewed-by: Damien Neil <[email protected]>
1 parent 9f24bb4 commit 6960703

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

http2/transport.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,10 +560,11 @@ func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Res
560560
traceGotConn(req, cc, reused)
561561
res, err := cc.RoundTrip(req)
562562
if err != nil && retry <= 6 {
563+
roundTripErr := err
563564
if req, err = shouldRetryRequest(req, err); err == nil {
564565
// After the first retry, do exponential backoff with 10% jitter.
565566
if retry == 0 {
566-
t.vlogf("RoundTrip retrying after failure: %v", err)
567+
t.vlogf("RoundTrip retrying after failure: %v", roundTripErr)
567568
continue
568569
}
569570
backoff := float64(uint(1) << (uint(retry) - 1))
@@ -572,7 +573,7 @@ func (t *Transport) RoundTripOpt(req *http.Request, opt RoundTripOpt) (*http.Res
572573
timer := backoffNewTimer(d)
573574
select {
574575
case <-timer.C:
575-
t.vlogf("RoundTrip retrying after failure: %v", err)
576+
t.vlogf("RoundTrip retrying after failure: %v", roundTripErr)
576577
continue
577578
case <-req.Context().Done():
578579
timer.Stop()

0 commit comments

Comments
 (0)