Add retries if resource doesn't exist
This commit is contained in:
parent
289e0f8c67
commit
3c2b8e0096
|
@ -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") ||
|
||||
|
|
Loading…
Reference in New Issue