Skip to content

Commit d20c351

Browse files
authored
Merge pull request avast#125 from haaawk/fix_124
Make sure DelayType function gets consistent values of n
2 parents 79a35c4 + 8d7cef7 commit d20c351

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

retry.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ func DoWithData[T any](retryableFunc RetryableFuncWithData[T], opts ...Option) (
202202
if n == config.attempts-1 {
203203
break
204204
}
205-
205+
n++
206206
select {
207207
case <-config.timer.After(delay(config, n, err)):
208208
case <-config.context.Done():
@@ -213,7 +213,6 @@ func DoWithData[T any](retryableFunc RetryableFuncWithData[T], opts ...Option) (
213213
return emptyT, append(errorLog, config.context.Err())
214214
}
215215

216-
n++
217216
shouldRetry = shouldRetry && n < config.attempts
218217
}
219218

0 commit comments

Comments
 (0)