From fde37814a75bb652b23ce449aecaf0b6897580b5 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Mon, 29 Apr 2024 11:20:27 +0100 Subject: [PATCH] Add delay to LDB retry after ENOTFOUND error. Signed-off-by: Fred Boniface --- src/services/ldb.services.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/services/ldb.services.js b/src/services/ldb.services.js index 98cc786..724bf2f 100644 --- a/src/services/ldb.services.js +++ b/src/services/ldb.services.js @@ -141,6 +141,7 @@ async function staffApiCallRetry(api, method, options, retries) { logger.warn(err, "DNS ERR") if (i < retries - 1) { logger.debug('Retrying API Call') + await delay(500) continue; } } @@ -150,6 +151,10 @@ async function staffApiCallRetry(api, method, options, retries) { throw new Error("Max retries exceeded"); } +function delay(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); +} + async function getReasonCodeList() { logger.debug("ldbService.getReasonCodeList: Fetching reason code list"); try {