From c7bdb5804ad274a36919e7555c0ed6a4f8bc20cb Mon Sep 17 00:00:00 2001 From: Evan Morikawa Date: Fri, 24 Feb 2017 10:58:21 -0800 Subject: [PATCH] [client-sync] fix unbouded query Summary: Fixes T7783 This unbounded query, plus a yet-to-be-diagnosed bug causing large numbers of messages with no folderIds, led to frequent crashes of the worker window at the end of every sync loop. This took a fair amount to diagnose. Notes on that are here: https://paper.dropbox.com/doc/Diagnosing-Crash-X329VTxevrqtIMESBtHNV Huge thanks to @mark. Test Plan: Reboot app with patch, no more crashes! Reviewers: spang, halla, mark, juan Reviewed By: mark, juan Subscribers: mark Maniphest Tasks: T7783 Differential Revision: https://phab.nylas.com/D4039 --- packages/client-sync/src/local-sync-worker/sync-worker.es6 | 4 ++++ 1 file changed, 4 insertions(+) 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 d27b71a95..84a2e4a16 100644 --- a/packages/client-sync/src/local-sync-worker/sync-worker.es6 +++ b/packages/client-sync/src/local-sync-worker/sync-worker.es6 @@ -101,6 +101,8 @@ class SyncWorker { const {Message, Thread, Folder, Label} = this._db; const messagesWithoutFolder = await Message.findAll({ + attributes: ['id', 'threadId'], + limit: 1000, where: { folderId: null, isSent: {$not: true}, @@ -116,6 +118,8 @@ class SyncWorker { }) .map(syncbackRequest => syncbackRequest.props.messageId) const messagesWithoutImapUID = await Message.findAll({ + attributes: ['id', 'threadId'], + limit: 1000, where: { folderImapUID: null, },