From 5a209a00f01fee7b9e96d252adeddc4ec66ff340 Mon Sep 17 00:00:00 2001 From: nathangray Date: Thu, 17 Jun 2021 14:17:58 -0600 Subject: [PATCH] Avoid infinite loop if loading JS file fails --- api/js/jsapi/egw_files.js | 2 ++ api/js/jsapi/egw_json.js | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/api/js/jsapi/egw_files.js b/api/js/jsapi/egw_files.js index d8d824ea5c..dd40eceac7 100644 --- a/api/js/jsapi/egw_files.js +++ b/api/js/jsapi/egw_files.js @@ -164,6 +164,7 @@ egw.extend('files', egw.MODULE_WND_LOCAL, function(_app, _wnd) promise = import(_prefix ? _prefix+src : src) .catch((err) => { console.error(src+": "+err.message); + return Promise.reject(err.message); }); } else @@ -172,6 +173,7 @@ egw.extend('files', egw.MODULE_WND_LOCAL, function(_app, _wnd) import(_prefix ? _prefix+src : src) .catch((err) => { console.error(src+": "+err.message); + return Promise.reject(err.message); }) })); } diff --git a/api/js/jsapi/egw_json.js b/api/js/jsapi/egw_json.js index cd9c7b6ed5..eeb6c78cff 100644 --- a/api/js/jsapi/egw_json.js +++ b/api/js/jsapi/egw_json.js @@ -538,7 +538,8 @@ egw.extend('json', egw.MODULE_WND_LOCAL, function(_app, _wnd) else if (i == 1 && parts[0] == 'app' && typeof app.classes[parts[1]] === 'undefined') { return this.includeJS('/'+parts[1]+'/js/app.js', undefined, undefined, this.webserverUrl) - .then(() => this.applyFunc(_func, args, _context)); + .then(() => this.applyFunc(_func, args, _context), + (err) => {console.error("Failure loading /"+parts[1]+'/js/app.js' + " (" + err + ")\nAborting.")}); } // check if we need a not yet instantiated app.js object --> instantiate it now else if (i == 1 && parts[0] == 'app' && typeof app.classes[parts[1]] === 'function')