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

fix to ensure to call requestdone() when requestkey is valid #1558

Merged
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
11 changes: 9 additions & 2 deletions src/core/common/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ func limitConcurrentRequests(requestKey string, limit int) bool {
// requestDone decreases the request counter
func requestDone(requestKey string) {
count, _ := clientRequestCounter.Load(requestKey)
if count == nil {
return
}
currentCount := count.(int)

if currentCount > 0 {
Expand Down Expand Up @@ -193,12 +196,16 @@ func ExecuteHttpRequest[B any, T any](
}

if err != nil {
requestDone(requestKey)
if method == "GET" {
requestDone(requestKey)
}
return fmt.Errorf("[Error from: %s] Message: %s", url, err.Error())
}

if resp.IsError() {
requestDone(requestKey)
if method == "GET" {
requestDone(requestKey)
}
return fmt.Errorf("[Error from: %s] Status code: %s, Message: %s", url, resp.Status(), resp.Body())
}

Expand Down