You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-18 05:42:00 +03:00
Retry /initialSync if it fails (exp backoff up to 2.1min).
This commit is contained in:
@@ -1878,8 +1878,10 @@ MatrixClient.prototype.isLoggedIn = function() {
|
||||
* @param {MatrixClient} client
|
||||
* @param {integer} historyLen
|
||||
* @param {integer} includeArchived
|
||||
* @param {integer} attempt
|
||||
*/
|
||||
function doInitialSync(client, historyLen, includeArchived) {
|
||||
function doInitialSync(client, historyLen, includeArchived, attempt) {
|
||||
attempt = attempt || 1;
|
||||
var qps = { limit: historyLen };
|
||||
if (includeArchived) {
|
||||
qps.archived = true;
|
||||
@@ -1980,8 +1982,12 @@ function doInitialSync(client, historyLen, includeArchived) {
|
||||
client.emit("syncComplete");
|
||||
_pollForEvents(client);
|
||||
}, function(err) {
|
||||
console.error("/initialSync error: %s", err);
|
||||
console.error("/initialSync error (%s attempts): %s", attempt, err);
|
||||
client.emit("syncError", err);
|
||||
attempt += 1;
|
||||
setTimeout(function() {
|
||||
doInitialSync(client, historyLen, includeArchived, attempt);
|
||||
}, Math.pow(2, Math.min(attempt, 7)) * 1000); // max 2^7 secs = 2.1 mins
|
||||
// TODO: Retries.
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user