diff --git a/data/utilities/retryRequest.js b/data/utilities/retryRequest.js index 891fdf3e..72b640ab 100644 --- a/data/utilities/retryRequest.js +++ b/data/utilities/retryRequest.js @@ -5,22 +5,28 @@ export default function retryRequest(requestFunction, ...args) { let waitTime = 1 const request = async () => { + + let ret + try { - return requestFunction(...args) + ret = await requestFunction(...args) } catch (e) { - if (e.response?.status == 429) { + if (e.response.status == 429) { waitTime *= 2 console.warn(`\nHit rate limit. Retrying after ${ waitTime }ms.`) await setTimeout(waitTime) - return request() + ret = await request() + } else { + throw e } - throw e - } + + return ret + } return request()