Add retries if resource doesn't exist

This commit is contained in:
Aditya Thakral 2021-09-03 16:05:40 -04:00
parent 289e0f8c67
commit 3c2b8e0096
1 changed files with 5 additions and 3 deletions

View File

@ -125,14 +125,16 @@ ${converter.makeMarkdown(abstract ?? "")}
* @param {string} url
*/
async function resourceExists(url) {
const time = Math.trunc(Math.random() * 10000);
await sleep(time);
const timer = setTimeout(() => console.log("not done", time, url), time + 3000);
const timer = setTimeout(() => {
console.log("retrying", time, url);
resourceExists(url);
}, time + 3000);
const response = await fetch(url);
clearTimeout(timer)
clearTimeout(timer);
return (
response.status.toString().startsWith("2") ||