Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle the first /sync failure differently. #216

Merged
merged 3 commits into from
Sep 23, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions lib/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,13 +545,22 @@ SyncApi.prototype._sync = function(syncOptions) {
console.error("/sync error %s", err);
console.error(err);

debuglog("Starting keep-alive");
self._syncConnectionLost = true;
self._startKeepAlives().done(function() {
if (!self._syncConnectionLost) {
// This is the first failure, which may be spurious. To avoid unnecessary
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"which may be spurious" - Can you give examples on this please as per RL discussion. Namely that things like restarting servers / load balancers / etc will knife any ongoing connection, and we want to effectively ignore that case.

// 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);
});
self._currentSyncRequest = null;
self._updateSyncState("ERROR", { error: err });
} else {
debuglog("Starting keep-alive");
self._syncConnectionLost = true;
self._startKeepAlives().done(function() {
self._sync(syncOptions);
});
self._currentSyncRequest = null;
self._updateSyncState("ERROR", { error: err });
}
});
};

Expand Down