You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-29 16:43:09 +03:00
Revert "Handle the first /sync failure differently."
This commit is contained in:
27
lib/sync.js
27
lib/sync.js
@@ -545,28 +545,13 @@ 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) {
|
debuglog("Starting keep-alive");
|
||||||
// This is the first failure, which may be spurious. To avoid unnecessary
|
self._syncConnectionLost = true;
|
||||||
// connection error warnings we simply retry the /sync immediately. Only
|
self._startKeepAlives().done(function() {
|
||||||
// if *that* one fails too do we say the connection has been lost.
|
|
||||||
// Examples of when this may happen are:
|
|
||||||
// - Restarting backend servers. (In an HA world backends may be
|
|
||||||
// restarted all the time, and its easiest just to make the
|
|
||||||
// client retry).
|
|
||||||
// - Intermediate proxies restarting.
|
|
||||||
// - Device network changes.
|
|
||||||
// Should we emit a state like "MAYBE_CONNETION_LOST"?
|
|
||||||
self._syncConnectionLost = true;
|
|
||||||
self._sync(syncOptions);
|
self._sync(syncOptions);
|
||||||
} else {
|
});
|
||||||
debuglog("Starting keep-alive");
|
self._currentSyncRequest = null;
|
||||||
self._syncConnectionLost = true;
|
self._updateSyncState("ERROR", { error: err });
|
||||||
self._startKeepAlives().done(function() {
|
|
||||||
self._sync(syncOptions);
|
|
||||||
});
|
|
||||||
self._currentSyncRequest = null;
|
|
||||||
self._updateSyncState("ERROR", { error: err });
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -332,13 +332,9 @@ describe("MatrixClient", function() {
|
|||||||
httpLookups = [];
|
httpLookups = [];
|
||||||
httpLookups.push(PUSH_RULES_RESPONSE);
|
httpLookups.push(PUSH_RULES_RESPONSE);
|
||||||
httpLookups.push(FILTER_RESPONSE);
|
httpLookups.push(FILTER_RESPONSE);
|
||||||
// We fail twice since the SDK ignores the first error.
|
|
||||||
httpLookups.push({
|
httpLookups.push({
|
||||||
method: "GET", path: "/sync", error: { errcode: "NOPE_NOPE_NOPE" }
|
method: "GET", path: "/sync", error: { errcode: "NOPE_NOPE_NOPE" }
|
||||||
});
|
});
|
||||||
httpLookups.push({
|
|
||||||
method: "GET", path: "/sync", error: { errcode: "NOPE_NOPE_NOPE2" }
|
|
||||||
});
|
|
||||||
httpLookups.push({
|
httpLookups.push({
|
||||||
method: "GET", path: "/sync", data: SYNC_DATA
|
method: "GET", path: "/sync", data: SYNC_DATA
|
||||||
});
|
});
|
||||||
@@ -359,13 +355,9 @@ describe("MatrixClient", function() {
|
|||||||
|
|
||||||
it("should transition SYNCING -> ERROR after a failed /sync", function(done) {
|
it("should transition SYNCING -> ERROR after a failed /sync", function(done) {
|
||||||
var expectedStates = [];
|
var expectedStates = [];
|
||||||
// We fail twice since the SDK ignores the first error.
|
|
||||||
httpLookups.push({
|
httpLookups.push({
|
||||||
method: "GET", path: "/sync", error: { errcode: "NONONONONO" }
|
method: "GET", path: "/sync", error: { errcode: "NONONONONO" }
|
||||||
});
|
});
|
||||||
httpLookups.push({
|
|
||||||
method: "GET", path: "/sync", error: { errcode: "NONONONONO2" }
|
|
||||||
});
|
|
||||||
|
|
||||||
expectedStates.push(["PREPARED", null]);
|
expectedStates.push(["PREPARED", null]);
|
||||||
expectedStates.push(["SYNCING", "PREPARED"]);
|
expectedStates.push(["SYNCING", "PREPARED"]);
|
||||||
@@ -404,10 +396,6 @@ describe("MatrixClient", function() {
|
|||||||
|
|
||||||
it("should transition ERROR -> ERROR if multiple /sync fails", function(done) {
|
it("should transition ERROR -> ERROR if multiple /sync fails", function(done) {
|
||||||
var expectedStates = [];
|
var expectedStates = [];
|
||||||
// We fail twice since the SDK ignores the first error.
|
|
||||||
httpLookups.push({
|
|
||||||
method: "GET", path: "/sync", error: { errcode: "NONONONONO" }
|
|
||||||
});
|
|
||||||
httpLookups.push({
|
httpLookups.push({
|
||||||
method: "GET", path: "/sync", error: { errcode: "NONONONONO" }
|
method: "GET", path: "/sync", error: { errcode: "NONONONONO" }
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user