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 {MatrixClient} client
|
||||||
* @param {integer} historyLen
|
* @param {integer} historyLen
|
||||||
* @param {integer} includeArchived
|
* @param {integer} includeArchived
|
||||||
|
* @param {integer} attempt
|
||||||
*/
|
*/
|
||||||
function doInitialSync(client, historyLen, includeArchived) {
|
function doInitialSync(client, historyLen, includeArchived, attempt) {
|
||||||
|
attempt = attempt || 1;
|
||||||
var qps = { limit: historyLen };
|
var qps = { limit: historyLen };
|
||||||
if (includeArchived) {
|
if (includeArchived) {
|
||||||
qps.archived = true;
|
qps.archived = true;
|
||||||
@@ -1980,8 +1982,12 @@ function doInitialSync(client, historyLen, includeArchived) {
|
|||||||
client.emit("syncComplete");
|
client.emit("syncComplete");
|
||||||
_pollForEvents(client);
|
_pollForEvents(client);
|
||||||
}, function(err) {
|
}, function(err) {
|
||||||
console.error("/initialSync error: %s", err);
|
console.error("/initialSync error (%s attempts): %s", attempt, err);
|
||||||
client.emit("syncError", 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.
|
// TODO: Retries.
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user