I have configured a Polly IAsyncPolicy using the following code:
IAsyncPolicy retryPolicy = Policy .Handle<HttpRequestException>(e => !e.IsBadRequest()) .WaitAndRetryAsync( Backoff.DecorrelatedJitterBackoffV2("00:00:01", 5), onRetry: (response, timeSpan, retryCount, context) => { if (!context.TryGetLogger(out var logger)) { return; } logger.LogWarning($"Retrying call {retryCount} with timespan: {timeSpan} due to: {response.Message}"); }); This is injected into the class as a Singleton and used in the following manner:
var context = new Context($"API-call-{Guid.NewGuid()}", new Dictionary<string, object> { { "logger", _logger }, }); await _resiliencePolicy.ExecuteAsync(async ctx => await _apiClient.Post.Delete(2), _context); The issue occurs when a retry is made, the original url https://someurl.com/post/2 now becomes https://someurl.com/post/22 (two is repeated) and this keeps happening for each retry. For say the 10th retry the URL would be https://someurl.com/post/222222222
Any ideas would be greatly appreciated.
_apiClient.Post.Delete(2)do?