You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
Handle the first /sync failure differently.
A /sync request may spuriously fail on occasion, without the "connection" actually being lost. To avoid spurious "Connection Lost" warning messages we ignore the first /sync and immediately retry, and only if that fails do we enter an ERROR state.
This commit is contained in:
@@ -545,6 +545,14 @@ SyncApi.prototype._sync = function(syncOptions) {
|
|||||||
console.error("/sync error %s", err);
|
console.error("/sync error %s", err);
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
|
||||||
|
if (!self._syncConnectionLost) {
|
||||||
|
// This is the first failure, which may be spurious. To avoid unnecessary
|
||||||
|
// connection error warnings we simply retry the /sync immediately. Only
|
||||||
|
// if *that* one fails too do we say the connection has been lost.
|
||||||
|
// Should we emit a state like "MAYBE_CONNETION_LOST"?
|
||||||
|
self._syncConnectionLost = true;
|
||||||
|
self._sync(syncOptions);
|
||||||
|
} else {
|
||||||
debuglog("Starting keep-alive");
|
debuglog("Starting keep-alive");
|
||||||
self._syncConnectionLost = true;
|
self._syncConnectionLost = true;
|
||||||
self._startKeepAlives().done(function() {
|
self._startKeepAlives().done(function() {
|
||||||
@@ -552,6 +560,7 @@ SyncApi.prototype._sync = function(syncOptions) {
|
|||||||
});
|
});
|
||||||
self._currentSyncRequest = null;
|
self._currentSyncRequest = null;
|
||||||
self._updateSyncState("ERROR", { error: err });
|
self._updateSyncState("ERROR", { error: err });
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user