Commit 8a6b914e authored by Guy Watson's avatar Guy Watson
Browse files

Add more fetch-retry logic

parent e853c37c
......@@ -97,16 +97,22 @@ function crcMemory(wasm_memory){
// Fetch retry function to help chromium fetch the wasm file
// https://dev.to/ycmjason/javascript-fetch-retry-upon-failure-3p6g
const fetch_retry = async (url, n) => {
let response = await fetch(url);
if(!response.ok) {
if (n === 1) {
throw Error("" + response.status + ": " + response.statusText);
} else {
return await fetch_retry(url, n - 1);
}
} else {
return response
let response;
try {
response = await fetch(url);
} catch(err) {
if (n === 1) {
throw err;
}
return await fetch_retry(url, n - 1);
}
if(!response.ok) {
if (n === 1) {
throw Error("" + response.status + ": " + response.statusText);
}
return await fetch_retry(url, n - 1);
}
return response;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment