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