Commit graph

5735 commits

Author SHA1 Message Date
Evan Morikawa 559ecb1cda [client-app] rename DatabaseTransaction -> DatabaseWriter
Summary: Renamed in prep for next few diffs

Test Plan: manual

Reviewers: juan, mark, spang, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4302
2017-03-30 17:38:07 -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
Mark Hahnenberg 9270ff6c4c [client-app] Add script that benchmarks new commits
Summary:
We want to setup the initial sync benchmark to run automatically with each
commit on a separate machine. This script does just that and dumps the
results to a directory. We can then have a separate script process them
and upload them to whichever service we want.

Test Plan: Run locally

Reviewers: evan, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4296
2017-03-30 16:11:49 -07:00
Mark Hahnenberg 5c08018382 [client-app] Add search support for "has:attachment"
Summary: See title

Test Plan: Run locally, verify that attachments are returned

Reviewers: spang, evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4293
2017-03-30 16:11:19 -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
Juan Tejada 2d1a3714d8 [client-app] Update changelog 2017-03-30 10:18:48 -07:00
Evan Morikawa b72e0829f2 [client-app] Add silent flag to DB persists for thread indexing
Summary:
Every persistModel would trigger a large number of downstream updates.
These weren't necessary for thread indexing and causing a lot of
unnecessary DB thrashing. This adds a `silent` flag to `persistModel` and
its ilk that just does the write.

significantly improve performance, and also contribute to T8046

Test Plan: manual

Reviewers: spang, mark, halla, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4295
2017-03-30 09:36:07 -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
Nylas Coffee Machine 5196f0eee7 bump(version): 1.0.52 2017-03-29 23:50:58 -07:00
Mark Hahnenberg df1acb84b1 [client-app] Fix thread reindexing loop
Summary:
We would mark modified threads for reindexing, the thread search indexer
would reindex them, which would trigger a notification that the thread
had been modified, so we would mark the thread for reindexing, ...

Now we keep track in memory of which threads we've marked for reindexing
so we avoid re-marking them when the update notification arrives later.

Test Plan:
Run locally, verify same threads aren't getting continuously
reindexed and that the in-memory set doesn't grow unboundedly

Reviewers: spang, juan, evan

Reviewed By: juan, evan

Differential Revision: https://phab.nylas.com/D4289
2017-03-29 17:00:40 -07:00
Mark Hahnenberg fa50657af1 [client-app] Add initial sync benchmarking script
Summary:
We want to be able to benchmark initial sync, so this diff adds two
scripts. The first, drop-stuff.sh, drops all data from the app and sync
databases that isn't related to account credentials. The second,
benchmark-initial-sync.sh, runs a fixed number of iterations (current 5) that
invokes drop-stuff.sh then opens the app, waits a fixed amount of time
(currently 120 seconds), and then kills the app and measures how many messages
it synced which it prints to the console. This is sufficient for us to start
measuring how quickly we can sync messages. This diff also includes the
sqlite3 amalgamation which drop-stuff.sh requires to function correctly
due to depending on the FTS5 extension which doesn't come built-in on
some platforms.

Test Plan: Run benchmark locally

Reviewers: evan, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4275
2017-03-29 16:11:44 -07:00
Juan Tejada c7e4c2bb87 [client-app] Fix references to RetryableError imports
Summary: See title

Test Plan: manual

Reviewers: spang, mark

Reviewed By: mark

Differential Revision: https://phab.nylas.com/D4292
2017-03-29 15:51:09 -07:00
Juan Tejada caac7cd247 [client-app] Log duration of db ANALYZE query
Summary: See title

Test Plan: manual

Reviewers: mark, halla, evan

Reviewed By: halla, evan

Differential Revision: https://phab.nylas.com/D4290
2017-03-29 15:01:31 -07:00
Juan Tejada ec51e982eb [client-app] Improve logging for queries
Summary:
This commit makes a few changes to how we log database queries:

- We log queries in 2 different places now:
  - When `DatabaseStore._executeLocally` takes longer than 100ms. This might be due to the actual db operation taking long, or it might be due to our retry logic, or potentially other factors.
  - When the actual raw database operation takes more than 100ms.
- When raw database queries take more than 100ms, we log out the query plan if it is a `SELECT` query and we are in dev mode.
- If `DEBUG_TO_LOG` is true, we always log all queries (including background queries)

Test Plan: manual

Reviewers: mark, halla, evan

Reviewed By: halla, evan

Differential Revision: https://phab.nylas.com/D4288
2017-03-29 15:01:07 -07:00
Juan Tejada d26a3e7448 [client-app] Improve logging for background database queries
Summary:
- Rename `databaseAgent` usage to `background`, in the code and in the logs, which I
believe is less confusing. Often times found myself asking what was this agent thing in
the logs.
- Make messaging more explicit

Test Plan: manual

Reviewers: evan, mark, halla

Reviewed By: mark, halla

Differential Revision: https://phab.nylas.com/D4285
2017-03-29 15:00:44 -07:00
Juan Tejada 8e03ca65ef [client-app] Reduce max retry delay for db queries
Summary:
This commit makes it so that when we retry database queries after
encountering a db locked error, we back off for at most 500ms, instead
of the current max of 3s. This meant that a single query could
potentially take 3+ seconds and block the transaction queue for that long.

Test Plan: manual

Reviewers: evan, mark, halla

Reviewed By: mark, halla

Differential Revision: https://phab.nylas.com/D4283
2017-03-29 15:00:12 -07:00
Juan Tejada 745dac7582 [client-app] Don't delay db queries unless we are retrying
Summary:
After introducing retry logic, we would always defer db queries to the
next tick even if there was no retry delay present.

This would cause almost all db queries take more than 100ms even if the
actual db operation was really fast. This affected app performance
negatively

Test Plan: manual

Reviewers: evan, halla, mark

Reviewed By: halla, mark

Differential Revision: https://phab.nylas.com/D4282
2017-03-29 14:59:34 -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
Mark Hahnenberg 69aa71e575 [client-app] Reindex threads when they're updated
This commit is the same as 7d409f5.

This commit was accidentally reverted in 95ec679, because I (juan) was being
dumb. So I'm re-committing here.

Summary:
We weren't doing that, so we would have accurate search index info for
threads when they were, e.g., moved to another folder.

Test Plan: Run locally

Reviewers: spang, evan, juan

Reviewed By: evan, juan

Differential Revision: https://phab.nylas.com/D4260
2017-03-29 11:55:28 -07:00
Christine Spang c2a0df174f [dev] Default billing server URL to staging for development, allow override
Summary:
By default, the 'local'/'development' environment assumes that all services
are running locally. This makes sense.

However, if you're not making changes to auxiliary services such as
billing.nylas.com and hence do not have them running locally, firing up
Nylas Mail with the 'local' env will not work. It's a bit of a pain to
get a local billing service running locally, especially if you're not
making any changes to that service. To ease development, change the
default billing URL during development to staging, and allow manually
overriding the billing server URL to point to localhost in the case
that you're making changes to the billing service also.

To override the billing URL for local development, run like this:

    npm run cloud -- --env billing_local
    BILLING_URL=http://billing.lvh.me:5555 npm start

This is both a problem that I've run into during development as well as
(my hunch) why Karim accidentally landed a global override of the
billing server URL.

Test Plan: manual

Reviewers: evan, khamidou, halla, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4202
2017-03-29 11:12:47 -07:00
Juan Tejada 7e123d4894 [client-app] Update changelog 2017-03-29 10:52:37 -07:00
Nylas Coffee Machine 8e7e8ef833 bump(version): 1.0.51 2017-03-28 23:07:37 -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
Christine Spang 9eabfa516f [dev] One more newline in deploy-it output 2017-03-28 17:02:45 -07:00
Christine Spang f0cd18eaa7 [dev] Make deploy-it print link to the EB console 2017-03-28 17:00:18 -07:00
Christine Spang a214d9118f [dev] Make deploy-it say what it's doing instead of hanging silently 2017-03-28 16:59:02 -07:00
Christine Spang e9be7168bc [dev] Make help message better on deploy-it 2017-03-28 16:47:02 -07:00
Evan Morikawa 9a7ce16616 [client-app] add SHOW_HOT_WINDOW env for prod debugging of window launches 2017-03-28 16:31:27 -07:00
Evan Morikawa 212dd4439a [client-app] properly relaunch windows on autoupdate 2017-03-28 16:15:02 -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
Juan Tejada e347ba2f90 [dev] Correctly ignore node_modules in .ebignore for faster deploys
Summary: See https://github.com/lovell/sharp/issues/373#issuecomment-226849756

Test Plan: manual

Reviewers: khamidou, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D4273
2017-03-28 14:00:29 -07:00
Juan Tejada b8883cd2b7 [dev] Only bootstrap specific pkgs in postinstall for faster installs
Summary:
This commit makes it so postinstall.es6 only bootstraps the packages we
are interested in based on a new env variable, `INSTALL_TARGET`.

`INSTALL_TARGET` can be set to `cloud`, `client` or `all`, or not set at all,
and our postinstall will bootstrap the packages accordingly. This will make
build and deploy times faster.

Test Plan: manual

Reviewers: spang, halla, evan, khamidou

Reviewed By: evan, khamidou

Differential Revision: https://phab.nylas.com/D4271
2017-03-28 13:59:55 -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 da018c3639 [client-app] Report battery state changes to Mixpanel
Summary:
This diff will give us insight into how people use Nylas Mail on their
computers with respect to how mobile they are (i.e. whether they use NM
on battery or plugged in).

Test Plan: Run locally

Reviewers: evan, spang, juan

Reviewed By: juan

Subscribers: gleb

Differential Revision: https://phab.nylas.com/D4267
2017-03-28 10:53:31 -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
Evan Morikawa da74dc2c18 [client-app] change file description on Windows 2017-03-28 09:56:29 -07:00
Juan Tejada 254b8dfb90 [client-app] Update changelog 2017-03-28 09:23:00 -07:00
Nylas Coffee Machine cc61b32710 bump(version): 1.0.50 2017-03-28 09:18:03 -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 1a1db50a84 [client-app] Update changelog 2017-03-28 09:10:15 -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