File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed
Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -175,8 +175,8 @@ func DoWithData[T any](retryableFunc RetryableFuncWithData[T], opts ...Option) (
175175 attemptsForError [err ] = attempts
176176 }
177177
178- shouldRetry := true
179- for shouldRetry {
178+ shouldRetry:
179+ for {
180180 t , err := retryableFunc ()
181181 if err == nil {
182182 return t , nil
@@ -194,13 +194,15 @@ func DoWithData[T any](retryableFunc RetryableFuncWithData[T], opts ...Option) (
194194 if errors .Is (err , errToCheck ) {
195195 attempts --
196196 attemptsForError [errToCheck ] = attempts
197- shouldRetry = shouldRetry && attempts > 0
197+ if attempts <= 0 {
198+ break shouldRetry
199+ }
198200 }
199201 }
200202
201203 // if this is last attempt - don't wait
202204 if n == config .attempts - 1 {
203- break
205+ break shouldRetry
204206 }
205207 n ++
206208 select {
@@ -212,8 +214,6 @@ func DoWithData[T any](retryableFunc RetryableFuncWithData[T], opts ...Option) (
212214
213215 return emptyT , append (errorLog , context .Cause (config .context ))
214216 }
215-
216- shouldRetry = shouldRetry && n < config .attempts
217217 }
218218
219219 if config .lastErrorOnly {
You can’t perform that action at this time.
0 commit comments