From c7ce750e926fcf423e3c08a3b542c27c238b2aff Mon Sep 17 00:00:00 2001 From: Madeline <46743919+MaddyUnderStars@users.noreply.github.com> Date: Wed, 22 Feb 2023 13:16:43 +1100 Subject: Client patcher now attempts assets multiple times, in case net sucks --- scripts/client.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/client.js b/scripts/client.js index 1320cb2c..6f297b1e 100644 --- a/scripts/client.js +++ b/scripts/client.js @@ -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 []; -- cgit 1.4.1