Skip to content

Commit f0e7b9a

Browse files
fix: add retry delay to WorldBank HTTP requests to handle transient 502 errors
The WorldBank type provider makes live HTTP requests at compile time to populate the country/indicator/region/topic types. Previously, retries happened immediately with no delay, meaning all 5 retries would fail in rapid succession during transient server-side outages (e.g. 502 Bad Gateway). Add a 2-second delay between retries so that brief API outages are more likely to be survived before all retries are exhausted. Fixes #1748 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 3884515 commit f0e7b9a

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)