From 055d55b71b2430850f758378513e75e69fa27745 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 1 Nov 2016 21:39:49 -0700 Subject: retry liveupdate up to 10 times if we receive incomplete/truncated html data. --- view/js/main.js | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'view/js/main.js') diff --git a/view/js/main.js b/view/js/main.js index 5435dfd87..6c7e90807 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -249,7 +249,7 @@ var divmore_height = 400; var last_filestorage_id = null; var mediaPlaying = false; var contentHeightDiff = 0; - +var liveRecurse = 0; $(function() { $.ajaxSetup({cache: false}); @@ -762,6 +762,27 @@ function liveUpdate() { var dstart = new Date(); console.log('LOADING data...'); $.get(update_url, function(data) { + + // on shared hosts occasionally the live update process will be killed + // leaving an incomplete HTML structure, which leads to conversations getting + // truncated and the page messed up if all the divs aren't closed. We will try + // again and give up if we can't get a valid HTML response after 10 tries. + + if((data.indexOf("") != (-1)) && (data.indexOf("") == (-1))) { + console.log('Incomplete data. Reloading'); + in_progress = false; + liveRecurse ++; + if(liveRecurse < 10) { + liveUpdate(); + } + else { + console.log('Incomplete data. Too many attempts. Giving up.'); + } + } + + // else data was valid - reset the recursion counter + liveRecurse = 0; + var dready = new Date(); console.log('DATA ready in: ' + (dready - dstart)/1000 + ' seconds.'); -- cgit v1.2.3