cloudwego / cloudwego/hertz

HTTP Client custom retry function whether this situation will be abnormal

Open
#920 2 comments 0 reactions 0 assignees View on GitHub
NeedsInvestigation
Dominant language
Go
Stars
7.4k
Forks
643
Avg merge
14h 5m
Merged PRs (30d)
2

Description

**Describe the Question**

The http Client custom retry function will have an exception when canIdempotentRetry is false?
**Reproducible Code**

![image](https://github.com/cloudwego/hertz/assets/5662295/b8ffc2ae-730a-41f7-bcf3-5f4236b328f1)

**Expected behavior**

if canIdempotentRetry && client.DefaultRetryIf(req, resp, err) && errors.Is(err, errs.ErrBadPoolConn) {
connAttempts++
continue
}

if isDefaultRetryFunc {
break
}

attempts++
if attempts >= maxAttempts {
break
}

// Check whether this request should be retried
if canIdempotentRetry && !isRequestRetryable(req, resp, err) {
break
}

Would it be better to write like this?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.