[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
This commit is contained in:
Evan Morikawa 2017-02-24 10:58:21 -08:00
parent 15eac9c9db
commit c7bdb5804a

View file

@ -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,
},