Commit graph

99 commits

Author SHA1 Message Date
Mark Hahnenberg 70bb602246 [client-sync] Split Contact ranking query
Summary:
We were using a join for the contact ranking query and for whatever
reason on large databases this was extremely slow in SQLite. This diff
splits the query into first finding the sent Folder/Label and then
searching for non-draft Messages in that category.

Test Plan: Run locally, verify the query is faster

Reviewers: juan, evan, spang

Reviewed By: spang

Differential Revision: https://phab.nylas.com/D4315
2017-03-31 15:29:20 -07:00
Mark Hahnenberg 0205ac3f61 [client-sync] Simplify Contact ranking query
Summary:
We were using a couple of left outer joins to avoid checking whether we
should be joining on Labels or Folders. We can greatly simplify the query
by just checking which we should use and issuing the correct inner join.

Test Plan: Run locally, verify contact ranking still works.

Reviewers: spang, juan, evan

Reviewed By: juan, evan

Differential Revision: https://phab.nylas.com/D4310
2017-03-31 12:19:58 -07:00
Juan Tejada 590b17ae6f [client-app] Don't imeout removing sync worker when removing an account
Summary:
Most of the times when removing a sync worker (i.e. when removing an
account), we would see database errors in the console. This happened
because more often than not we would interrupt in the middle of message
processing, but `processMessage` is not interruptible, which means that
the worker would be interrupted right after processing its current
message. However, if `processMessage` would take more than 500ms (the
current timeout for stopping the worker), we would destroy the database
before processing was done and it would throw a bunch of errors.

To fix this, we just don't set a timeout when removing the worker as a consequence
of removing an account. However, when we are removing the worker when we
detect that it is stuck, we set a time out of 5 seconds.

Test Plan: manually test removing accounts, verify that it doesn't error

Reviewers: mark, halla, evan

Reviewed By: halla, evan

Differential Revision: https://phab.nylas.com/D4308
2017-03-31 12:09:20 -07:00
Juan Tejada 9181914453 [client-app] Ensure sync worker can never continue running after being destroyed
Summary:
Previously, it was possible for the sync worker to continue running after being
interrupted, e.g. it would break out of `performSync` and then try to run
`onSyncCompleted`. This is fine if we were just interrupting to restart the loop,
but when we stop it we don't want it to continue running anything at all.

This also refactors the syncworker to have a single `destroy` method, which sets
a `destroyed` flag and uses that one exclusively instead of the `stopped` flag.

Test Plan: manually check it works

Reviewers: spang, halla, mark, evan

Reviewed By: mark, evan

Differential Revision: https://phab.nylas.com/D4307
2017-03-31 12:08:48 -07:00
Halla Moore af6e6e669a [client-sync] Wrap more syncWorker args
Turns out the SyncWorker isn't the only one who initiates SyncTasks
2017-03-31 11:12:50 -07:00
Halla Moore ae2e2122e9 [client-sync] Properly wrap the SyncWorker arg in an object
The argument structure for runTask() changed and needs it this way.
2017-03-31 10:58:16 -07:00
Halla Moore c6a339df1a [client-sync] Fix the new syncback-task structure
Summary:
- Change files to .es6 so they recognize the syntax
- Pass arguments down to _run()
- Make sure the responses get returned

Test Plan: manual, even though that somehow failed before. :(

Reviewers: evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4309
2017-03-31 10:52:42 -07:00
Evan Morikawa f9c0a93d1c [client-app] use debug library for DB
Summary:
Use the wonderful `debug` library instead of all our random flags.
You can now do things like: `DEBUG="app:*,sync:*" npm start` to print out
everything.

Test Plan: manual

Reviewers: mark, halla, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4297
2017-03-30 17:26:33 -07:00
Halla Moore f5f5b60140 [client-sync] Add provider to syncbackTask perf metric 2017-03-30 16:24:32 -07:00
Halla Moore a776e6dfb7 [client-sync] Report metrics about SyncbackTask runs
Summary:
Report how long they take and if they're stopped (due to timeout).

Part of T7978

Test Plan: manual

Reviewers: evan, juan

Reviewed By: evan, juan

Differential Revision: https://phab.nylas.com/D4272
2017-03-30 16:15:09 -07:00
Halla Moore 4c1af8f184 [client-sync] Convert syncback tasks to interruptible generators
Summary:
Make `run()` functions generators and change most awaits to yields

Part of T7978

Test Plan: specs from D4269, but really needs some heavy QA

Reviewers: evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4270
2017-03-30 15:51:25 -07:00
Halla Moore c11a7ff830 [client-sync] Interrupt long-running syncback tasks
Summary:
Interrupt retryable syncback tasks that are taking too long so that we can
return control to the sync loop. The sync loop will retry the task later.
This diff adds a `forceReject` param to `interrupt()` so that we can return
control immediately instead of waiting for the current operation to finish
(for instance, the syncback task could be stuck in an imap operation, and a
normal interrupt would still have to wait for that to finish before returning
control to the callee)

Part of T7978

Test Plan: specs

Reviewers: evan, spang, mark, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4269
2017-03-30 15:50:34 -07:00
Evan Morikawa 2b67f139ea [client-app] Add better DB logging with ENABLE_SEQUELIZE_DEBUG_LOGGING
Summary:
This adds better logging to the DB

You can use `ENABLE_SEQUELIZE_DEBUG_LOGGING=true` and
`ENABLE_RXDB_DEBUG_LOGGING=true` to spit out the raw queries of both DBs.

Test Plan: manual

Reviewers: mark, halla, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4294
2017-03-30 09:32:52 -07:00
Evan Morikawa 9d15ff7ff7 [client-app] ensure gmail msg to 1 person get tracking stripped
Summary:
The problem actually was that we weren't applying the transform for Gmail
messages sent to 1 recipient

Test Plan: manual

Reviewers: halla, juan

Reviewed By: halla, juan

Differential Revision: https://phab.nylas.com/D4291
2017-03-29 14:53:57 -07:00
Evan Morikawa d8e22aa936 [client-app] don't trigger your own opens & link clicks
Summary:
We weren't stripping link and open items from messages we sent properly.
While we stripped it from the first outgoing message, when the sync loop
came back around it would have them back in. This adds it in the message
processor to extra ensure that ANYTHING that comes from us (or one of our
aliases) gets the open/link tracking stripped

Test Plan: New tests

Reviewers: juan, halla

Reviewed By: juan, halla

Differential Revision: https://phab.nylas.com/D4287
2017-03-29 14:53:40 -07:00
Mark Hahnenberg 78b9cf81c5 [client-sync] Fix "in:" for IMAP search
Summary:
Prior to this diff, the "in:" search query syntax didn't work for IMAP.
This diff implements "in:" by changing the IMAP search backend to take
folder context into account and emit the appropriate queries for each
folder. Queries that include "in:foo" will replace the corresponding AST
nodes with 'ALL' or 'NOT ALL' depending on whether or not the current folder
is "foo". We also now filter which folders we search based on which
folders are referenced in the query.

Test Plan: Run locally, verify that in: works quickly

Reviewers: evan, juan, spang

Reviewed By: juan, spang

Differential Revision: https://phab.nylas.com/D4284
2017-03-29 13:48:46 -07:00
Juan Tejada ca50e6cf52 [client-sync] Make sure to attach route files ending in .es6 to local-api
Summary:
This prevented the /health endpoint from being available in the
local-api

Test Plan: manual

Reviewers: mark, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4280
2017-03-28 17:50:59 -07:00
Juan Tejada 6202a4618e [client-sync] Fix runtime error introduced in 08975c0
Summary:
If `gmailInitialUIDsRemaining` was defined, we need to set `initialUids`
to that value. We were previously setting it to a key in
`folder.syncState` that didn't exist, which caused a runtime error.

This was introduced in d6a2b6935c

Test Plan: manual

Reviewers: spang, mark

Reviewed By: mark

Differential Revision: https://phab.nylas.com/D4279
2017-03-28 16:00:06 -07:00
Christine Spang a57e4bdd20 [cloud-api] Verify SMTP credentials in /auth endpoint
Summary:
This patch will prevent users from being able to connect accounts which sync
mail but fail to send.

This commit includes a couple pieces:
* Adds a call to nodemailer's `verify()` function in the /auth endpoint
* Adds Error object conversion for SMTP errors. Since we don't implement our
  own connection object or connection pool for SMTP, we simply wrap the couple
  places we call functions from nodemailer that connect to SMTP, namely
  SendmailClient's _send() and the new verify() call in /auth.
* Moves RetryableError to the 'errors' module since it's now a base class for
  retryable IMAP //and// SMTP errors.
* Moves the main `smtpConfig()` logic which used to live on the Account model
  into AuthHelpers so it can be shared between the Account model and the verify
  code.
* Converts a few different places to use `import` syntax instead of
  `require` syntax for module imports. Apologies for not splitting this out
  into a separate diff—would have been a fair amount of work and looks not too
  difficult to skim over in the context of the rest of the patch.
* Fixing a bug in a previous commit where erroring sends would crash because of
  using `this._transporter.options` instead of `this._transporter.transporter.options`

Test Plan: manual

Reviewers: evan, halla, juan

Reviewed By: halla, juan

Differential Revision: https://phab.nylas.com/D4200
2017-03-28 15:47:44 -07:00
Juan Tejada 76234eaa9b [client-app] Correctly listen for new mail in between sync loops
Summary:
When using the IMAPConnectionPool in the sync-worker, we requested 2
connections from the pool: 1 to listen for new mail, and 1 to actually
operate on the mailbox. These 2 connections would be closed and returned
to the pool at the end of each sync loop iteration.

However, we never want to close the connection to listen for new mail.
Closing this connection caused us to not listen for new mail in between
sync loops, which was especially noticeable when initial sync was done
because the delay between sync loops is 5 minutes.

This commit makes it so we request the 2 connections separately from the
connection pool, and keep the listener connection always open until we
dispose of the sync-worker.

Test Plan:
manually make sure that I got new mail event listeners in between
sync loops :(

Reviewers: evan, spang, halla, mark

Reviewed By: mark

Differential Revision: https://phab.nylas.com/D4276
2017-03-28 14:09:41 -07:00
Juan Tejada cfb5c20fc1 [client-sync] 🎨 typo 2017-03-28 14:01:02 -07:00
Mark Hahnenberg d6a2b6935c [client-sync] Also prioritize sent label for initial Gmail sync
Summary:
Sent mail is important for initial sync because it's used for contact
ranking. Prior to this diff we would delay syncing sent mail because we
would prioritize the inbox label over all other labels (including sent).
This diff includes the sent folder in the initial set of messages to sync.

Test Plan: Run locally, verify we get sent mail quickly

Reviewers: evan, spang, juan

Reviewed By: spang

Differential Revision: https://phab.nylas.com/D4268
2017-03-28 11:25:21 -07:00
Mark Hahnenberg 0508180712 [client-sync] Don't throttle while syncing first 500 threads
Summary:
We want to get to a usable inbox as quickly as possible, and throttling
prevents this. We should basically only be throttling for historical
mail syncing.

Test Plan: Run initial sync benchmark, it's 117% faster on battery

Reviewers: evan, juan, spang

Reviewed By: juan, spang

Differential Revision: https://phab.nylas.com/D4266
2017-03-28 10:52:34 -07:00
Mark Hahnenberg 60e6113f87 [client-sync] Implement the /contacts/rankings endpoint
Summary:
Prior to Nylas Mail, the Nylas Cloud API provided an endpoint that
returned rankings for contacts which it computed based on how frequently
and how recently a user sent mail to a recipient. This diff reimplements
that functionality in Nylas Mail. This should improve contact
auto-complete when composing emails to frequently contacted recipients.

Test Plan: Run locally, verify that frequent contacts are suggested earlier

Reviewers: spang, evan, juan

Reviewed By: evan, juan

Maniphest Tasks: T7948

Differential Revision: https://phab.nylas.com/D4253
2017-03-28 10:51:24 -07:00
Juan Tejada ff9d49e752 [client-app] Fix runtime error in FetchMessagesInFolderTask
We were accessing `this._db.accountId` before `this._db` was set, which
caused an error when attempting to run the task
2017-03-28 09:15:03 -07:00
Juan Tejada caf5380659 [client-app] Fix importing SyncActivity
In some places we were not accessing `.default` when using `require`,
and when using `import` we couldn't really destructure unless we
accessed `.default` too, or if the functions were regular exports
instead of properties on a default exported object.

This was causing our sync loop to error.

To remain consistent, we always just `require` or `import` the
SyncActivity singleton and access that
2017-03-28 09:09:39 -07:00
Halla Moore adff6896e6 [client-sync] Change where we report sync activity
Summary:
These locations will provide enough activity for monitoring and are also
more helpful in helping us debug what the sync loop was doing when it
got stuck.

Test Plan: manual

Reviewers: juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4274
2017-03-27 21:49:56 -07:00
Halla Moore 4ad4596e2f [client-app, client-sync] Add specs for detecting stuck sync/worker window
Summary: See title. Part of T7681.

Test Plan: ran the specs

Reviewers: evan, mark, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4264
2017-03-27 15:45:33 -07:00
Halla Moore 619c69a522 [client-sync] Detect when sync workers are stuck
Summary:
Periodically check the latest sync activity times to determine if a sync
worker has been inactive for too long. If it has been too long, discard
the worker and create a new one for that account. Part of T7681.

Test Plan: manual, specs

Reviewers: evan, mark, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4262
2017-03-27 15:41:31 -07:00
Halla Moore b6887e386e [client-sync] Report latest sync activity
Summary:
Add infrastructure to report and retrieve the latest sync activity, and
start reporting when we download a message or detect that a folder
has no new messages. This will be used to detect if the sync loop is
stuck. Part of T7681.

Test Plan: manual, specs

Reviewers: evan, mark, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4261
2017-03-27 15:39:53 -07:00
Juan Tejada ae1c667e37 [client-app] Fix in identity store 2017-03-24 14:04:44 -07:00
Juan Tejada 41ad424752 [client-app] Don't try to restart sync on every IdentityStore change
Summary:
The IdentityStore can trigger any number of times, but we only want to
start sync if we previously didn't have an identity available

Test Plan: manual

Reviewers: spang, evan, halla

Reviewed By: evan, halla

Differential Revision: https://phab.nylas.com/D4246
2017-03-24 13:06:47 -07:00
Mark Hahnenberg 4ef8e7614e [client-sync] Don't handle IMAP timeouts in the connection pool
Summary:
Different clients can have different policies for retrying after
timeouts.

Test Plan: Run locally, run tests

Reviewers: evan, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4247
2017-03-23 11:33:53 -07:00
Mark Hahnenberg 2fe8bee38f [client-sync] Refactor sync worker IMAPConnectionPool callbacks
Summary: In preparation for removing timeout handling from the IMAPConnectionPool.

Test Plan: Run locally

Reviewers: spang, evan, juan

Reviewed By: evan, juan

Differential Revision: https://phab.nylas.com/D4245
2017-03-21 12:15:40 -07:00
Juan Tejada 3554fb2510 [client-app] Fix passing cursor to delta streams
Summary:
Currently, when we auth an account for the first time in Nylas Mail (or
we blow away the database), the app is going to request transactions
since cursor `null` from the /delta/streaming endpoint and from the local-sync
delta observable, instead of requesting transactions since cursor `0`

This is due to a subtle bug with the use of default values when
destructuring an object. Our coded did the following:
```
const {cursor = 0} = this._state
```
Which at a glance seems correct. However, this will only work as
expected if `this._state` has the following shape:
```
{cursor: undefined}
```
And unfortunately, our `this._state` looked like this when authing an
account for the first time:
```
{cursor: null}
```

Which would make `cursor === null` instead of `0`.
This is because when using default values, null is considered an
intentional argument/value, as opposed to not passing any argument/value
(which will mean that the argument is undefined).

This was a regression introduced in d60a23c and 8bc2ec5

Test Plan: manual, will add regression test in upcoming diff

Reviewers: evan, spang, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4243
2017-03-20 16:16:46 -07:00
Juan Tejada 6532d3c647 [client-sync] Add error handling when creating syncback requests
Summary: see title. also convert to es6

Test Plan: manual

Reviewers: evan, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4225
2017-03-17 13:59:37 -07:00
Halla Moore 4492b73507 [client-sync] Only update lastReceivedDate if the message was actually received
Summary:
We don't want to bump threads to the top of the inbox when a user sends a
reply. We originally used `!isSent` to prevent this, but that was removed in
a diff that made sure messages showed up in the inbox when users send emails
to themselves. In order to implement both of these cases properly, this diff
introduces `isReceived` and uses that to determine whether lastReceivedDate
should be updated. Addresses T7991.

Also changes the order of some `or` statements, so that we actually check that
the variable exists before comparing against it.

Test Plan: manual

Reviewers: evan, juan, spang

Reviewed By: spang

Differential Revision: https://phab.nylas.com/D4226
2017-03-16 12:25:56 -07:00
Juan Tejada 7fc1e043c1 [client-app] Restart sync when computer awakes from sleep
Summary:
Use electron's `powerMonitor` module to detect when the computer resumes
from sleep, and restart the sync loop when that happens in order to
sync the inbox immediately, in case we received any new mail events
while the computer was asleep

Test Plan: manual

Reviewers: evan, spang, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4216
2017-03-13 22:44:09 -07:00
Juan Tejada f157ddb867 [client-app] Make resetEmailCache work without forcing re sign-in
Summary:
This commit makes it so `resetEmailCache` works as expected, i.e. it
removes all databases, without forcing the user to re sign-in to their
accounts or NylasID

Previously, this method removed the database without removing the
accounts, left users in an un-authed state that was hard to recover
from. This was fixed in D4212 which makes sure that when we get a new
identity, sync and deltas are restarted

However, resetEmailCache would still force you to log in to yoru NylasID
because it was deleted from the database. However, if we reuse the
command `application:relaunch-to-initial-windows` instead of manually
deleting the database, we can relaunc the app while preserving the users
NylasID session, so they don't have to sign back in manually.

Test Plan: manual

Reviewers: evan, spang, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4215
2017-03-13 22:42:52 -07:00
Juan Tejada 4d1628b914 [client-app] Don't start sync or delta connections without an identity
Summary:
This prevents the app from entering a restart loop when there's no
identity.

Specifically, when a user logs out of their identity, or when she resets the
email cache, or any other scenario that leaves the app without an
identity but with accounts added, the sync loop (and deltas) will start
without an Identity.

This will cause NylasAPIRequest to throw an error that
forces the user to close the app. When the app restarts, sync will start
again without an identity, and the user will be forced to close the app
again, and so on and so forth for the rest of eternity

Relevant error:
https://github.com/nylas/nylas-mail-all/blob/master/packages/client-app/src/flux/nylas-api-request.es6#L165-L174

Additionaly, this makes sure that after resetting the email cache, the sync
process starts when the identity becomes available

This solves T7989

Test Plan: manual

Reviewers: evan, spang, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4212
2017-03-13 20:00:59 -07:00
Juan Tejada 588163acda [client-sync] Correctly wait for sync to stop before resetting email cache
Summary:
Previously, while resetting the email cache, we would try to stop sync
and just wait for an arbitraty amount of time for it to stop and the
proceed to blow away the database.

This commit makes it so we correctly wait for sync to stop, and then we
blow away the db. It adds a timeout anyway in case sync is stuck and we
can't stop it

Depends on D4207

Test Plan: manual

Reviewers: evan, spang, halla

Reviewed By: spang, halla

Differential Revision: https://phab.nylas.com/D4209
2017-03-13 19:57:58 -07:00
Juan Tejada ebe16aa1ae [client-sync]: Fix error in SyncProcessManager._resetEmailCache
Summary:
We no longer keep `this._accounts` state, which was being accessed
inside `_resetEmailCache`

Test Plan: manual

Reviewers: evan, spang, halla

Reviewed By: spang, halla

Differential Revision: https://phab.nylas.com/D4207
2017-03-13 19:56:37 -07:00
Mark Hahnenberg 595adde687 [client-sync] Fix queueMessageForProcessing
Summary:
We were always incrementing the queue length and resolving the promise
in the constructor :-/

Test Plan: Run locally, make sure queue doesn't start rejecting messages

Reviewers: evan, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4198
2017-03-10 17:39:35 -08:00
Mark Hahnenberg 792994d95c [client-sync] Refactor MessageProcessor to be more robust to errors
Summary:
Errors in the MessageProcessor were causing sync to get stuck
occasionally. This diff refactors queueMessageForProcessing and friends
so that they're more robust to errors during promise construction.

Test Plan: Run locally

Reviewers: juan, spang, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D4190
2017-03-10 13:40:04 -08:00
Mark Hahnenberg c971ed03e2 [client-sync] Shim sequelize to timeout after 1 minute
Summary:
Sequelize can sometimes return promises that will never resolve or
reject. We can wrap the promises we get back from sequelize in a
bluebird promise which gives us the ability to timeout these abandoned
promises. This way, we can track down issues in sequelize as well as
unblocking stuck sync loops.

Test Plan: Run locally, verify that timeouts occur

Reviewers: juan, evan, spang

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D4192
2017-03-10 13:39:27 -08:00
Juan Tejada d24fc9a235 [client-app] More defensive error handling to prevent sync from halting
Summary:
This commit adds error handling to the sync-loop's `onSyncError` and
`scheduleNextSync`.

These functions generally don't fail, as they are in the `catch` and
`finally` blocks respectively of the sync loop. But as we've seen in
D4152, the datbase can sometime error if it's in a bad state. If it
errors inside these functions, we will never schedule the next run of
the sync loop.

Depends on D4152

Test Plan: manual

Reviewers: evan, spang, mark, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4153
2017-03-09 21:22:07 -08:00
Juan Tejada da463c250f [client-app] Consolidate delta connection stores, rm deltas internal_pkg
Summary:
This commit consolidates the `DeltaConnectionStatusStore` and the
`DeltaConnectionStore` which kept track of very similar state and made
sense to be the same store (as per feedback in D4118#77647)

Given that this state needs to be available app-wide for plugins to
query the status of delta connections, `internal_packages/deltas` was
removed (given that it only activated that store), in favor of having the
unified store inside `src/flux/stores` and available via `nylas-exports`

The `deltas` package also contained some contacts-ranking code, which is
no longer in use until we restore that fetaure, so I created a
`internal_packages/contact-rankings` which contains this unused code for
now.

Test Plan:
manually open, close, end delta connections, verify that I'm getting
correct results. unit tests to come

Reviewers: halla, spang, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D4145
2017-03-09 15:27:06 -08:00
Juan Tejada 20a05d3340 [client-app] Rate limit error reporting for message processing errors
Summary:
This should prevent us from flooding Sentry with errors like this one:
https://sentry.io/nylas/nylas-mail/issues/230605150/

Test Plan: manual

Reviewers: spang, mark, halla, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D4151
2017-03-09 15:22:08 -08:00
Juan Tejada 521ca86efc [client-app] Prevent database malformed error restart loop
Summary:
This error is can flood Sentry pretty badly: https://sentry.io/nylas/nylas-mail/issues/230629801/

My initial thought was to rate limit it, but rate limiting wouldn't
do any good because when we get that error we destroy the databases and
restart the app, and we will loose the in-memory rate limiting data.

The real fix, and reason why Sentry is being flooded with this error by
a single user, is that once you encounter this error the app will enter
a restart loop that constantly throws this error. The reason being that
we weren't properly awaiting for the K2 account databases to be dropped
before closing the app, so on restart, the database would still be
malformed.

The fix is to properly `await` for the database drops

Test Plan: manual

Reviewers: spang, mark, halla, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D4127
2017-03-09 15:21:07 -08:00
Mark Hahnenberg 6a17073fe5 [client-sync] Refactor file download IMAP pool use
Summary:
This is in preparation for removing the ability of the IMAP pool to
automatically handle timeout errors.

Test Plan: Run locally, verify file download still works

Reviewers: juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4167
2017-03-09 14:47:07 -08:00