Skip to content

Commit 038ec9d

Browse files
committed
http2: do not retry dial if request context canceled
When request context is canceled or expired, do not retry on dialing to the server.
1 parent 022530c commit 038ec9d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

http2/client_conn_pool.go

+4
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,10 @@ func shouldRetryDial(call *dialCall, req *http.Request) bool {
300300
// from this request.
301301
return false
302302
}
303+
if req.Context().Err() != nil {
304+
// If the request is canceled or expired, should not retry.
305+
return false
306+
}
303307
if !errors.Is(call.err, context.Canceled) && !errors.Is(call.err, context.DeadlineExceeded) {
304308
// If the call error is not because of a context cancellation or a deadline expiry,
305309
// the dial should not be retried.

0 commit comments

Comments
 (0)