From e89975456b6b28a089accecb50df30af70bb480d Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Tue, 12 Jul 2016 18:31:55 -0700 Subject: [PATCH] Fix scenario where sync worker is re-assigned the same account before fully releasing it --- packages/nylas-sync/sync-process-manager.js | 3 ++- packages/nylas-sync/sync-worker.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/nylas-sync/sync-process-manager.js b/packages/nylas-sync/sync-process-manager.js index 3d205c384..d1ee98c9f 100644 --- a/packages/nylas-sync/sync-process-manager.js +++ b/packages/nylas-sync/sync-process-manager.js @@ -194,13 +194,14 @@ class SyncProcessManager { const dst = ACCOUNTS_UNCLAIMED; return PubsubConnector.broadcastClient().lremAsync(src, 1, accountId).then((didRemove) => { + this._workers[accountId] = null; + if (didRemove) { PubsubConnector.broadcastClient().rpushAsync(dst, accountId) } else { this._logger.error("Wanted to return item to pool, but didn't have claim on it.") return } - this._workers[accountId] = null; }); } } diff --git a/packages/nylas-sync/sync-worker.js b/packages/nylas-sync/sync-worker.js index 992ef3a52..1b6c7c801 100644 --- a/packages/nylas-sync/sync-worker.js +++ b/packages/nylas-sync/sync-worker.js @@ -225,6 +225,7 @@ class SyncWorker { this._account.lastSyncCompletions = lastSyncCompletions this._account.save() + this._logger.info('Syncworker: Completed sync cycle') if (afterSync === 'idle') {