From eaf3c888a464df80a76ccca49eba42902c93d45a Mon Sep 17 00:00:00 2001 From: Peter Murray Date: Sun, 31 May 2020 15:32:52 +0100 Subject: [PATCH] Related to #172, changing ordering in case of success to ensure that references to state are correctly set before clearing promise reference and displaying error message if the async request fails --- lib/api/Api.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/api/Api.js b/lib/api/Api.js index 432d4fb..8ad4d24 100644 --- a/lib/api/Api.js +++ b/lib/api/Api.js @@ -165,11 +165,12 @@ module.exports = class Api { } self._syncPromise = self._syncPromise.then(data => { - self._syncPromise = null; self._state = new Cache(data); self._lastSyncTime = new Date().getTime(); + self._syncPromise = null; }) - .catch(() => { + .catch(err => { + console.error(`Failed to async load the bridge configuration data; ${err}`); self._syncPromise = null; }); }