diff --git a/customize.dist/translations/messages.js b/customize.dist/translations/messages.js index 02f682d4d..6fc608855 100644 --- a/customize.dist/translations/messages.js +++ b/customize.dist/translations/messages.js @@ -36,6 +36,8 @@ define(function () { out.synced = "Everything is saved"; out.deleted = "Pad deleted from your CryptDrive"; + out.realtime_unrecoverableError = "The realtime engine has encountered an unrecoverable error. Click OK to reload."; + out.disconnected = 'Disconnected'; out.synchronizing = 'Synchronizing'; out.reconnecting = 'Reconnecting...'; diff --git a/www/common/cryptpad-common.js b/www/common/cryptpad-common.js index 8af4c045a..d8547d4a4 100644 --- a/www/common/cryptpad-common.js +++ b/www/common/cryptpad-common.js @@ -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);