From 76dc3e0b9856296195c0ee5588062fb79d233099 Mon Sep 17 00:00:00 2001 From: omgbeez <251408589+omgbeez@users.noreply.github.com> Date: Sat, 14 Mar 2026 09:32:51 -0400 Subject: [PATCH] fix: Long retry-after would generate timeout instead of RateLimitException Needed to move the retry handler before the TimeOut handler, and drive the throw from the TimeOut configured by the user for the provider. --- server/RdtClient.Service/DiConfig.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/server/RdtClient.Service/DiConfig.cs b/server/RdtClient.Service/DiConfig.cs index 9fc21f0..b23fcae 100644 --- a/server/RdtClient.Service/DiConfig.cs +++ b/server/RdtClient.Service/DiConfig.cs @@ -92,11 +92,6 @@ public static class DiConfig private static void ConfigureResiliencePipeline(ResiliencePipelineBuilder builder) { - builder.AddTimeout(new TimeoutStrategyOptions - { - TimeoutGenerator = _ => new(TimeSpan.FromSeconds(Settings.Get.Provider.Timeout)) - }); - builder.AddRateLimitHeaders(options => { options.EnableProactiveThrottling = true; @@ -120,8 +115,9 @@ public static class DiConfig if (args.Outcome.Result is { StatusCode: HttpStatusCode.TooManyRequests } response) { var delay = RateLimitHandler.GetRetryAfterDelay(response); + var timeout = TimeSpan.FromSeconds(Settings.Get.Provider.Timeout); - if (delay >= TimeSpan.FromMinutes(10)) + if (delay >= timeout) { return new ValueTask((TimeSpan?)null); } @@ -132,5 +128,10 @@ public static class DiConfig return new((TimeSpan?)null); } }); + + builder.AddTimeout(new TimeoutStrategyOptions + { + TimeoutGenerator = _ => new(TimeSpan.FromSeconds(Settings.Get.Provider.Timeout)) + }); } }