Skip to content

Commit 6d90255

Browse files
fix: resolve vscode type errors inside retryer module (#4614)
Co-authored-by: Alexandr <[email protected]>
1 parent f023d9e commit 6d90255

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

src/common/retryer.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,30 @@ const retryer = async (fetcher, variables, retries = 0) => {
6666
// finally return the response
6767
return response;
6868
} catch (err) {
69+
/** @type {any} */
70+
const e = err;
71+
72+
// network/unexpected error → let caller treat as failure
73+
if (!e?.response) {
74+
throw e;
75+
}
76+
6977
// prettier-ignore
7078
// also checking for bad credentials if any tokens gets invalidated
71-
const isBadCredential = err.response.data && err.response.data.message === "Bad credentials";
79+
const isBadCredential =
80+
e?.response?.data?.message === "Bad credentials";
7281
const isAccountSuspended =
73-
err.response.data &&
74-
err.response.data.message === "Sorry. Your account was suspended.";
82+
e?.response?.data?.message === "Sorry. Your account was suspended.";
7583

7684
if (isBadCredential || isAccountSuspended) {
7785
logger.log(`PAT_${retries + 1} Failed`);
7886
retries++;
7987
// directly return from the function
8088
return retryer(fetcher, variables, retries);
81-
} else {
82-
return err.response;
8389
}
90+
91+
// HTTP error with a response → return it for caller-side handling
92+
return e.response;
8493
}
8594
};
8695

0 commit comments

Comments
 (0)