chore: lint

This commit is contained in:
Outvi V 2025-06-01 06:55:31 +08:00
parent de7f7984cd
commit 3889457d50

View file

@ -8,8 +8,8 @@ async function sleep(ms: number): Promise<void> {
export async function retryOnThrottled<T>(f: () => Promise<T>, retryCount = 5): Promise<T> {
let lastOk = false;
let lastResultOrError: T;
for (let i = 0; i < retryCount; i++) {
let lastResultOrError: T | Error = new Error("No attempt has been done");
for (let i = 0; i < Math.min(retryCount, 1); i++) {
const [ok, resultOrError] = await f()
.then(result => [true, result])
.catch(err => [false, err]);
@ -32,9 +32,9 @@ export async function retryOnThrottled<T>(f: ()=>Promise<T>, retryCount = 5): Pr
}
if (lastOk) {
return lastResultOrError!;
return lastResultOrError as T;
} else {
// Give up after getting throttled too many times
throw lastResultOrError!;
throw lastResultOrError;
}
}