Skip to content

Commit 4abfd83

Browse files
authored
Merge pull request #1749 from fsprojects/repo-assist/fix-worldbank-retry-delay-1748-271c6fc951eef501
[Repo Assist] fix: add retry delay to WorldBank HTTP requests (handles transient 502 errors)
2 parents 3884515 + c50316d commit 4abfd83

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/FSharp.Data.WorldBank.Core/WorldBankRuntime.fs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ open FSharp.Data.Runtime.Caching
1818
module Implementation =
1919

2020
let private retryCount = 5
21+
let private retryDelayMs = 2000 // 2 seconds between retries to handle transient API failures (e.g. 502 Bad Gateway)
2122
let private parallelIndicatorPageDownloads = 8
2223

2324
type internal IndicatorRecord =
@@ -85,6 +86,8 @@ module Implementation =
8586
Debug.WriteLine(sprintf "[WorldBank] error: %s" (e.ToString()))
8687

8788
if attempt > 0 then
89+
// Delay before retrying to handle transient server-side failures (e.g. 502 Bad Gateway)
90+
do! Async.Sleep retryDelayMs
8891
return! worldBankRequest (attempt - 1) funcs args
8992
else
9093
return! failwithf "Failed to request '%s'. Error: %O" url e

0 commit comments

Comments
 (0)