esperar entre pedidos fallidso

This commit is contained in:
Cat /dev/Nulo 2024-01-04 16:52:11 -03:00
parent 3c9788647b
commit df845acc66

View file

@ -33,6 +33,7 @@ export async function downloadList(path: string) {
async (urlS) => {
let res: ScrapResult = { type: "skipped" };
for (let attempts = 0; attempts < 3; attempts++) {
if (attempts !== 0) await wait(1500);
res = await scrap(urlS);
if (res.type === "done" || res.type === "skipped") {
break;
@ -101,3 +102,7 @@ async function scrap(urlS: string): Promise<ScrapResult> {
};
}
}
function wait(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}