1
0
mirror of https://github.com/spacebarchat/server.git synced 2024-11-25 11:43:07 +01:00

Client patcher now attempts assets multiple times, in case net sucks

This commit is contained in:
Madeline 2023-02-22 13:16:43 +11:00
parent fda13104ad
commit c7ce750e92
No known key found for this signature in database
GPG Key ID: 1958E017C36F2E47

View File

@ -201,7 +201,20 @@ const processFile = async (asset) => {
if (ONLY_CACHE_JS && !asset.endsWith(".js")) return [];
const url = `${BASE_URL}/assets/${asset}`;
const res = await fetch(url, { agent });
let res,
tries = 5;
do {
try {
res = await fetch(url, { agent });
} catch (e) {
await new Promise((resolve) => setTimeout(resolve, 100));
print(
`Failed to fetch ${url} : ${e.message} ( tries remaining: ${tries} )`,
false,
);
if (--tries <= 0) throw e;
}
} while (!res);
if (res.status !== 200) {
print(`${res.status} on ${asset}`, false);
return [];