resty icon indicating copy to clipboard operation
resty copied to clipboard

SetRetryCount allows negative values that Backoff doesn't properly handle

Open moorereason opened this issue 4 years ago • 3 comments

SetRetryCount allows values less than zero, but the Backoff implementation assumes opts.maxRetries is zero or greater. The result is that Backoff doesn't actually make a request but also doesn't return an error.

Two options for a solution:

  1. Convert negative values to zero in SetRetryCount.
  2. Convert a negative value into math.MaxInt64 (retry forever) in SetRetryCount.

In either case, Backoff should be updated to return an error if opts.maxRetries is less than zero.

Related to #392

moorereason avatar Jan 11 '21 14:01 moorereason

@yjhmelody commented here that option 2 (retry forever) is preferred.

I tend to agree. Normally, a -1 in this scenario means "no limit."

moorereason avatar Jan 12 '21 14:01 moorereason

@moorereason @yjhmelody Just wondering, the forever retry option is good or bad for the client library since it will result in DoS behavior on targeted application/service.

jeevatkm avatar Mar 21 '21 07:03 jeevatkm

Prevent -1 usage with error message

jeevatkm avatar Oct 01 '23 04:10 jeevatkm