abort the realtime session if it does not synchronize for 30 seconds
This commit is contained in:
@@ -202,13 +202,29 @@ define([
|
||||
return;
|
||||
};
|
||||
|
||||
common.infiniteSpinnerDetected = false;
|
||||
var whenRealtimeSyncs = common.whenRealtimeSyncs = function (realtime, cb) {
|
||||
realtime.sync();
|
||||
|
||||
window.setTimeout(function () {
|
||||
if (realtime.getAuthDoc() === realtime.getUserDoc()) {
|
||||
return void cb();
|
||||
}
|
||||
|
||||
var to = setTimeout(function () {
|
||||
realtime.abort();
|
||||
// don't launch more than one popup
|
||||
if (common.infiniteSpinnerDetected) { return; }
|
||||
|
||||
// inform the user their session is in a bad state
|
||||
common.confirm(Messages.realtime_unrecoverableError, function (yes) {
|
||||
if (!yes) { return; }
|
||||
window.location.reload();
|
||||
});
|
||||
common.infiniteSpinnerDetected = true;
|
||||
}, 30000);
|
||||
realtime.onSettle(function () {
|
||||
clearTimeout(to);
|
||||
cb();
|
||||
});
|
||||
}, 0);
|
||||
|
||||
Reference in New Issue
Block a user