The snooze call is skipped in the try block when the command throws an exception. As a result, the command tries maxTry times as fast as possible. The fix is to move the snooze call outside of the try block. PS: #GotMyUHK
This commit is contained in:
@@ -77,7 +77,6 @@ export async function retry(command: Function, maxTry = 3, logService?: LogServi
|
|||||||
try {
|
try {
|
||||||
// logService.debug(`[retry] try to run FUNCTION:\n ${command}, \n retry: ${retryCount}`);
|
// logService.debug(`[retry] try to run FUNCTION:\n ${command}, \n retry: ${retryCount}`);
|
||||||
await command();
|
await command();
|
||||||
await snooze(100);
|
|
||||||
// logService.debug(`[retry] success FUNCTION:\n ${command}, \n retry: ${retryCount}`);
|
// logService.debug(`[retry] success FUNCTION:\n ${command}, \n retry: ${retryCount}`);
|
||||||
return;
|
return;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@@ -93,6 +92,7 @@ export async function retry(command: Function, maxTry = 3, logService?: LogServi
|
|||||||
if (logService) {
|
if (logService) {
|
||||||
logService.info(`[retry] failed, but try run FUNCTION:\n ${command}, \n retry: ${retryCount}`);
|
logService.info(`[retry] failed, but try run FUNCTION:\n ${command}, \n retry: ${retryCount}`);
|
||||||
}
|
}
|
||||||
|
await snooze(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user