Skip to content

Commit

Permalink
http2: do not retry dial if request context canceled
Browse files Browse the repository at this point in the history
When request context is canceled or expired, do not retry on dialing to the server.
  • Loading branch information
Taction committed May 27, 2024
1 parent 022530c commit 038ec9d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions http2/client_conn_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ func shouldRetryDial(call *dialCall, req *http.Request) bool {
// from this request.
return false
}
if req.Context().Err() != nil {
// If the request is canceled or expired, should not retry.
return false
}
if !errors.Is(call.err, context.Canceled) && !errors.Is(call.err, context.DeadlineExceeded) {
// If the call error is not because of a context cancellation or a deadline expiry,
// the dial should not be retried.
Expand Down

0 comments on commit 038ec9d

Please sign in to comment.