From 931eb66b3f9da273988f9a5961d6134fa4500af1 Mon Sep 17 00:00:00 2001 From: "Costa Tsaousis (ktsaou)" Date: Tue, 20 Dec 2016 00:20:17 +0200 Subject: allow dashboards to retry fetching chart data on failures; fixes #1402 --- web/dashboard.js | 20 ++++++++++++++++++-- web/demosites.html | 5 ++++- web/index.html | 5 ++++- 3 files changed, 26 insertions(+), 4 deletions(-) (limited to 'web') diff --git a/web/dashboard.js b/web/dashboard.js index a62b31d4ae..0db567107a 100644 --- a/web/dashboard.js +++ b/web/dashboard.js @@ -332,6 +332,8 @@ async_on_scroll: false, // sync/async onscroll handler onscroll_worker_duration_threshold: 30, // time in ms, to consider slow the onscroll handler + retries_on_data_failures: 3, // how many retries to make if we can't fetch chart data from the server + setOptionCallback: function() { ; } }, @@ -1231,6 +1233,9 @@ // the chart library requested by the user this.library_name = self.data('chart-library') || NETDATA.chartDefaults.library; + // how many retries we have made to load chart data from the server + this.retries_on_data_failures = 0; + // object - the chart library used this.library = null; @@ -3077,6 +3082,7 @@ }) .done(function(data) { that.xhr = undefined; + that.retries_on_data_failures = 0; if(that.debug === true) that.log('data received. updating chart.'); @@ -3086,8 +3092,18 @@ .fail(function(msg) { that.xhr = undefined; - if(msg.statusText !== 'abort') - error('data download failed for url: ' + that.data_url); + if(msg.statusText !== 'abort') { + that.retries_on_data_failures++; + if(that.retries_on_data_failures > NETDATA.options.current.retries_on_data_failures) { + // that.log('failed ' + that.retries_on_data_failures.toString() + ' times - giving up'); + that.retries_on_data_failures = 0; + error('data download failed for url: ' + that.data_url); + } + else { + that.tm.last_autorefreshed = Date.now(); + // that.log('failed ' + that.retries_on_data_failures.toString() + ' times, but I will retry'); + } + } }) .always(function() { that.xhr = undefined; diff --git a/web/demosites.html b/web/demosites.html index 63a62d6966..e212e4cd0a 100644 --- a/web/demosites.html +++ b/web/demosites.html @@ -505,7 +505,7 @@ p { and that you have chown it to be owned by netdata:netdata --> - +