aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/app/js/launcher.js2
-rw-r--r--src/modules/requests.js15
2 files changed, 14 insertions, 3 deletions
diff --git a/src/app/js/launcher.js b/src/app/js/launcher.js
index 98f16dc..3130253 100644
--- a/src/app/js/launcher.js
+++ b/src/app/js/launcher.js
@@ -145,7 +145,7 @@ async function loadServers() {
// ask the masterserver for the list of servers, if this has
// been done recently, it'll simply return the cached version
let servers = JSON.parse(
- await request(host, path, "ns-servers")
+ await request(host, path, "ns-servers", false)
)
masterserver = true;
diff --git a/src/modules/requests.js b/src/modules/requests.js
index bc113bb..d4ee678 100644
--- a/src/modules/requests.js
+++ b/src/modules/requests.js
@@ -166,7 +166,7 @@ requests.cache.set = (cache_key, data) => {
// if `cache_key` is set, we'll first attempt to check if any valid
// cache with that key exists, and then return it directly if its still
// valid cache.
-requests.get = (host, path, cache_key, max_time_min) => {
+requests.get = (host, path, cache_key, ignore_max_time_when_offline = true, max_time_min) => {
let cached = requests.cache.get(cache_key, max_time_min);
if (cached) {
return cached;
@@ -207,8 +207,19 @@ requests.get = (host, path, cache_key, max_time_min) => {
})
})
- // an error occured, simply `reject()`
+ // an error occured
.on("error", () => {
+ if (ignore_max_time_when_offline) {
+ // check if the request has been cached before, at all, not
+ // caring about how long time ago it was, and if it was, we
+ // simply return that, as a last resort.
+ cached = requests.cache.get(cache_key, false);
+
+ if (cached) {
+ return resolve(cached);
+ }
+ }
+
reject(false);
})
})