fix: resolve vscode type errors inside retryer module (#4614)
Co-authored-by: Alexandr <qwerty541zxc@gmail.com>
This commit is contained in:
1 parent
f023d9e74c
commit
6d90255d05
1 file changed
+14
-5
+14
-5
@@ -66,21 +66,30 @@ const retryer = async (fetcher, variables, retries = 0) => {
|
|||||||
// finally return the response
|
// finally return the response
|
||||||
return response;
|
return response;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
/** @type {any} */
|
||||||
|
const e = err;
|
||||||
|
|
||||||
|
// network/unexpected error → let caller treat as failure
|
||||||
|
if (!e?.response) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
// prettier-ignore
|
// prettier-ignore
|
||||||
// also checking for bad credentials if any tokens gets invalidated
|
// 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 =
|
const isAccountSuspended =
|
||||||
err.response.data &&
|
e?.response?.data?.message === "Sorry. Your account was suspended.";
|
||||||
err.response.data.message === "Sorry. Your account was suspended.";
|
|
||||||
|
|
||||||
if (isBadCredential || isAccountSuspended) {
|
if (isBadCredential || isAccountSuspended) {
|
||||||
logger.log(`PAT_${retries + 1} Failed`);
|
logger.log(`PAT_${retries + 1} Failed`);
|
||||||
retries++;
|
retries++;
|
||||||
// directly return from the function
|
// directly return from the function
|
||||||
return retryer(fetcher, variables, retries);
|
return retryer(fetcher, variables, retries);
|
||||||
} else {
|
|
||||||
return err.response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// HTTP error with a response → return it for caller-side handling
|
||||||
|
return e.response;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user