diff --git a/packages/client-sync/src/local-sync-worker/sync-tasks/fetch-messages-in-folder.imap.es6 b/packages/client-sync/src/local-sync-worker/sync-tasks/fetch-messages-in-folder.imap.es6 index 3f85df8e8..ef9dcf093 100644 --- a/packages/client-sync/src/local-sync-worker/sync-tasks/fetch-messages-in-folder.imap.es6 +++ b/packages/client-sync/src/local-sync-worker/sync-tasks/fetch-messages-in-folder.imap.es6 @@ -471,7 +471,11 @@ class FetchMessagesInFolderIMAP extends SyncTask { if (savedSyncState.fetchedmin > savedSyncState.minUID) { const lowerbound = Math.max(savedSyncState.minUID, savedSyncState.fetchedmin - batchSize); // this._logger.log(`FetchMessagesInFolderIMAP: fetching ${lowerbound}:${savedSyncState.fetchedmin}`); - totalProcessedMessages += yield this._fetchAndProcessMessages({min: lowerbound, max: savedSyncState.fetchedmin}); + totalProcessedMessages += yield this._fetchAndProcessMessages({ + min: lowerbound, + max: savedSyncState.fetchedmin, + throttle: this._syncWorker.throttlingEnabled(), + }); } else { // this._logger.log("FetchMessagesInFolderIMAP: fetchedmin == minUID, nothing older to fetch.") } diff --git a/packages/client-sync/src/local-sync-worker/sync-worker.es6 b/packages/client-sync/src/local-sync-worker/sync-worker.es6 index 7cda3968b..1a61c2264 100644 --- a/packages/client-sync/src/local-sync-worker/sync-worker.es6 +++ b/packages/client-sync/src/local-sync-worker/sync-worker.es6 @@ -43,6 +43,7 @@ class SyncWorker { this._lastSyncTime = null this._interrupted = false this._syncInProgress = false + this._throttlingEnabled = false this._stopped = false this._destroyed = false this._shouldIgnoreInboxFlagUpdates = false @@ -82,6 +83,7 @@ class SyncWorker { }) } if (seen === 500) { + this._throttlingEnabled = true MetricsReporter.reportEvent({ nylasId, type: 'imap', @@ -99,6 +101,10 @@ class SyncWorker { } } + throttlingEnabled() { + return this._throttlingEnabled; + } + _getInboxFolder() { return this._db.Folder.find({where: {role: ['all', 'inbox']}}) }