summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/htdocs/luci-static
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2019-09-21 10:19:22 +0200
committerJo-Philipp Wich <jo@mein.io>2019-09-21 10:23:37 +0200
commitafeacdc7df181a592bea2109497400427e6471be (patch)
tree377855e599723a72ceba129b53acbc6fdfcc6903 /modules/luci-base/htdocs/luci-static
parentd24fa4ad61c42916a7420aaf2a519d6044af6ccb (diff)
luci-base: luci.js: improve XHR issue diagnostics
Differentiate between request timeouts and other error reasons. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/htdocs/luci-static')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/luci.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/luci.js b/modules/luci-base/htdocs/luci-static/resources/luci.js
index af2b179ce3..1d349ebc17 100644
--- a/modules/luci-base/htdocs/luci-static/resources/luci.js
+++ b/modules/luci-base/htdocs/luci-static/resources/luci.js
@@ -399,17 +399,21 @@
},
handleReadyStateChange: function(resolveFn, rejectFn, ev) {
- var xhr = this.xhr;
+ var xhr = this.xhr,
+ duration = Date.now() - this.start;
if (xhr.readyState !== 4)
return;
if (xhr.status === 0 && xhr.statusText === '') {
- rejectFn.call(this, new Error('XHR request aborted by browser'));
+ if (duration >= this.timeout)
+ rejectFn.call(this, new Error('XHR request timed out'));
+ else
+ rejectFn.call(this, new Error('XHR request aborted by browser'));
}
else {
var response = new Response(
- xhr, xhr.responseURL || this.url, Date.now() - this.start);
+ xhr, xhr.responseURL || this.url, duration);
Promise.all(Request.interceptors.map(function(fn) { return fn(response) }))
.then(resolveFn.bind(this, response))