Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[do not merge] Defer cancel in api client - Fixes issue #4973 #4974

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions api/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -644,11 +644,10 @@ START:
}

// Set the timeout, if any
var cancelFunc context.CancelFunc
if timeout != 0 {
var ctx context.Context
ctx, cancelFunc = context.WithTimeout(context.Background(), timeout)
ctx, cancelFunc := context.WithTimeout(context.Background(), timeout)
req.Request = req.Request.WithContext(ctx)
defer cancelFunc()
}

if backoff == nil {
Expand All @@ -667,9 +666,6 @@ START:

var result *Response
resp, err := client.Do(req)
if cancelFunc != nil {
cancelFunc()
}
if resp != nil {
result = &Response{Response: resp}
}
Expand Down