From ac3f96e2d41be66ab3eb3c403a2fd0b0bf90931c Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Fri, 15 Jul 2016 10:07:33 -0700 Subject: [PATCH] Fix accounts syncing in a hard loop due to redis loopback --- packages/nylas-sync/sync-worker.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/packages/nylas-sync/sync-worker.js b/packages/nylas-sync/sync-worker.js index 89e8ba95c..35d71597c 100644 --- a/packages/nylas-sync/sync-worker.js +++ b/packages/nylas-sync/sync-worker.js @@ -73,11 +73,14 @@ class SyncWorker { } _onAccountUpdated() { - if (!this.isWaitingForNextSync()) { + const syncingNow = !this.isWaitingForNextSync() + const syncingJustFinished = (Date.now() - this._lastSyncTime < 5000); + + if (syncingNow || syncingJustFinished) { return; } - this._getAccount() - .then((account) => { + + this._getAccount().then((account) => { this._account = account; this.syncNow({reason: 'Account Modification'}); })