From a6b8bc2052355a6ab671f12d6729ef50a44cdf4c Mon Sep 17 00:00:00 2001 From: Alexandr Garbuzov <186095128+alexandr-garbuzov@users.noreply.github.com> Date: Wed, 22 Oct 2025 21:53:48 +0300 Subject: [PATCH] fix: resolve vscode type errors inside retryer module (#4614) Co-authored-by: Alexandr --- backend/src/common/retryer.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/backend/src/common/retryer.js b/backend/src/common/retryer.js index 9327fe00..feecb4bf 100644 --- a/backend/src/common/retryer.js +++ b/backend/src/common/retryer.js @@ -66,21 +66,30 @@ const retryer = async (fetcher, variables, retries = 0) => { // finally return the response return response; } catch (err) { + /** @type {any} */ + const e = err; + + // network/unexpected error → let caller treat as failure + if (!e?.response) { + throw e; + } + // prettier-ignore // also checking for bad credentials if any tokens gets invalidated - const isBadCredential = err.response.data && err.response.data.message === "Bad credentials"; + const isBadCredential = + e?.response?.data?.message === "Bad credentials"; const isAccountSuspended = - err.response.data && - err.response.data.message === "Sorry. Your account was suspended."; + e?.response?.data?.message === "Sorry. Your account was suspended."; if (isBadCredential || isAccountSuspended) { logger.log(`PAT_${retries + 1} Failed due to bad credentials`); retries++; // directly return from the function return retryer(fetcher, variables, retries); - } else { - return err.response; } + + // HTTP error with a response → return it for caller-side handling + return e.response; } };