Commit graph

5881 commits

Author SHA1 Message Date
Juan Tejada 664da98c22 [*] Remove useless docs
Summary:
This makes grepping the codebase really painful. We don't need these
docs here

Test Plan: manual

Reviewers: mark halla spang evan

Subscribers:
2017-04-12 19:58:06 -07:00
Juan Tejada e4dcfa40b1 [client-app] Update changelog 2017-04-12 13:12:24 -07:00
Nylas Coffee Machine 3396254499 bump(version): 2.0.11 2017-04-12 12:13:03 -07:00
Mark Hahnenberg 8d4ef160a1 [client-sync] Dispose of mail listener connection before getting new one
Summary:
When we had to refresh our credentials for the mail listener connection we
weren't disposing of the old connection which caused us to slowly leak
connections from the IMAP connection pool, eventually requiring a
restart. Now we always dispose of the connection prior to requesting a
new one from the pool.

Test Plan: Run locally always refreshing credentials, verify we don't get stuck

Reviewers: spang, evan, halla, juan

Reviewed By: halla, juan

Subscribers: halla

Differential Revision: https://phab.nylas.com/D4414
2017-04-12 12:11:49 -07:00
Juan Tejada 811843f880 Revert "[client-sync] Poll for gmail attribute changes from _mailListenerIMAPConn"
This reverts commit 15c3e328fc.

See https://phab.nylas.com/D4410 for details on why it was reverted
2017-04-12 12:08:24 -07:00
Juan Tejada 1bf453dd4a [client-app] Don't double report unhandled rejections
Summary:
We listen for unhandled rejections on both the `process` and the `window`. From
my understanding, both are necessary because some errors might escape
one or the other. However, most errors get caught by both handlers, so
we don't want to double report them to sentry (or the console).

To prevent this, this commit debounces the unhandled rejection handler
for a very short time so that the same error only gets reported once.
Additionally, it rate limits reports to sentry based on the stack trace

Test Plan: manual

Reviewers: mark, halla

Reviewed By: mark, halla

Differential Revision: https://phab.nylas.com/D4413
2017-04-12 12:06:22 -07:00
Juan Tejada b6771ea745 [client-app] Fix unhandled rejection handling (fix ipc parse error)
Summary:
Previously, we were listening for unhanlded rejections on both the
`window` and the `process`. However, the window handler didn't receive
an error as a parameter, but rather a window event. When trying to
report this event and sending it over IPC we would get an ipc parse
error.

This commit makes it so we correctly report the error instead of the
window event.

Test Plan: manual

Reviewers: mark, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4412
2017-04-12 12:05:07 -07:00
Juan Tejada d30559aa6e Revert "[client-sync] Transaction-ify processMessage"
Summary:
This reverts commit c808438ee9.

Adding an overarching transaction to `processMessage` is causing
database locked errors when processing deltas, specifically when trying
to write to the Transaction table, given that that write happens
asynchronously inside the execution of `processMessage`, but doesn't
have access to its transaction. See T8117

Given that the performance gains from wrapping messgae processing in a
transaction were not significant, let's revert this to prevent db
locking issues

Test Plan: manual

Reviewers: halla, mark

Reviewed By: mark

Differential Revision: https://phab.nylas.com/D4411
2017-04-12 12:04:11 -07:00
Juan Tejada 8d9b247a95 [client-app] Rate limit database malformed error reports to sentry
Summary:
We were reporting 1m+ of these events, heavily contributing towards our
quota

Test Plan: manual

Reviewers: halla, mark

Reviewed By: halla, mark

Differential Revision: https://phab.nylas.com/D4406
2017-04-11 16:36:48 -07:00
Juan Tejada 58d2274faa [client-app] Update changelog 2017-04-11 15:41:30 -07:00
Nylas Coffee Machine 545f6a30da bump(version): 2.0.10 2017-04-11 13:34:47 -07:00
Juan Tejada 0525767518 [client-sync] Ensure allmail folder exists before trying to access it
Summary:
When checking for flag updates for gmail accounts, when syncing for the
first time the all mail folder won't be available because we haven't
fetched the folder list, so it will throw a runtime error

Test Plan: manual

Reviewers: mark, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4405
2017-04-11 12:36:39 -07:00
Halla Moore d226eaf4a7 [client-app] Fix SyncbackMetadataTask dependency
Summary:
Add a sequentialId check in isDependentOnTask() so that the first
SyncbackMetadataTask won't get blocked on other SyncbackMetadataTasks
in the queue for the same pluginId.

Addresses T8112

Test Plan: Manual

Reviewers: spang, mark, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4404
2017-04-11 12:22:57 -07:00
Halla Moore 61594021ae [isomorphic-core] Add missing .default to require 2017-04-11 11:09:39 -07:00
Halla Moore 840ebebecf [isomorphic-core] Move buildMime to MessageUtils, add includeBcc option
Summary:
Since buildMime isn't always used explictly for the send operation (we
mostly use it for stuffing the sent folder, which is a separate
operation), move it to MessageUtils. Additionally, add an includeBcc
option. We don't want the BCC header to be visible on outbound messages,
but it needs to be present on the version that is saved to the sent
folder.

When we weren't including the BCC header in the sent folder version, we
were getting an id mismatch between our optimistic message and the
message that gets processed by the sync loop (because we include the bcc
participants when computing the id hash). When the sent message was a
reply, the optimistic message included the threadId, and this had the
side effect of leaving both versions of the sent message in the thread.
Since the optimistic message never receieved it's imap UID, any action
performed on the thread would fail with the missing UID error as seen in
T7941. Adding this BCC header will allow us to compute the proper id
hash and reconcile the synced message with the optimistic message.

Test Plan: manual

Reviewers: evan, mark, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4365
2017-04-11 10:49:58 -07:00
Halla Moore 379edfe0b8 [*] MessageFactory -> MessageUtils, SendUtils -> ModelUtils
Summary: Rename some util files

Test Plan: manual

Reviewers: evan, mark, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4364
2017-04-11 10:49:30 -07:00
Halla Moore f82c72aa88 [client-sync] Don't report stuck sync processes to Sentry
Summary: Just to mixpanel. Addresses T8095

Test Plan: Meh

Reviewers: mark, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4403
2017-04-11 10:45:09 -07:00
Juan Tejada f6f8f16e25 [client-app] Update changelog 2017-04-11 10:37:13 -07:00
Nylas Coffee Machine a412580cad bump(version): 2.0.9 2017-04-11 08:12:13 -07:00
Halla Moore 15c3e328fc [client-sync] Poll for gmail attribute changes from _mailListenerIMAPConn
Summary:
Normally, the imap connection emits an 'update' event when there are any
flag changes. Gmail, however, only emits the 'update' event when there
are new or removed messages. If there's a fairly large batch size being
synced in the sync loop, we don't want to wait until the end of that to
check if the highestmodseq has changed. To get around this, this diff
updates the new mail listener connection to periodically poll for the
highestmodseq and trigger the same update handler when changes are
detected.

Test Plan: manual

Reviewers: evan, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4397
2017-04-10 15:46:02 -07:00
Halla Moore c6db6c3ae2 [client-app] Re-add imap to the onboarding accounts page
Summary:
Put the IMAP option back on the provider selection page within
onboarding. Also remove the 'hidden' property on account types since I
don't think we'll be using it for any other providers, and remove the
'Add Custom IMAP Account' from the application menu.

Addresses T8097

Test Plan: Manual

Reviewers: spang, mark, juan

Reviewed By: mark, juan

Differential Revision: https://phab.nylas.com/D4402
2017-04-10 15:44:26 -07:00
Juan Tejada 07d576d5f4 [client-app] Fix delta streaming connection retries
Summary:
Previously, every time our NylasLongConnection changed its status to
`connected`, we would reset our backoff scheduler, assuming that
every time our status changed to `connected` it meant that we would not
receive any errors.

However, if our backend is down or overloaded (or returning 401s like in
our recent outage), we would do the following:

1. Establish connection, change status to `connected`
2. Reset backoff scheduler
3. Receive error
4. Close connection
5. Schedule next retry using backoff scheduler. Delay will be 1s or less, because scheduler was reset in 2.
6. Retry after delay,
7. Repeat from 1., ad infinitum

This caused us to consistantly hammer our servers and render our
exponential backoff useless.

This commit makes it so we conly reset the backoff scheduler when we
actually receive deltas, and increments the max backoff to 10 minutes

Test Plan:
run against local n1Cloud, manually return 401s from the api, verify that we
didn't backoff at all before this diff, verify that we backoff correctly after
this diff

Reviewers: mark, spang, halla

Reviewed By: mark, spang, halla

Differential Revision: https://phab.nylas.com/D4401
2017-04-10 15:08:48 -07:00
Halla Moore e8957b787e [isomorphic-core] Handle weird MIME edge case with @ symbol
Summary:
Something weird happens with the mime building when the participant name
has an @ symbol in it (e.g. a name and email of hello@gmail.com turns
into 'hello@ <gmail.com hello@gmail.com>'), so replace it with
whitespace.

Test Plan: manual

Reviewers: evan, mark, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4363
2017-04-10 12:40:22 -07:00
Mark Hahnenberg be4b0d773c [client-app] Add benchmark mode
Summary:
There are some settings that apply to dev and prod modes that we don't want
to use while benchmarking. E.g. the folder where we store messages,
whether we generate long stack traces in our bluebird promises, etc.
This diff adds a benchmark mode so that we can change these settings to
something that works better for benchmarking.

Test Plan: Run locally, verify it works

Reviewers: evan, juan, spang

Reviewed By: juan, spang

Differential Revision: https://phab.nylas.com/D4374
2017-04-07 15:33:57 -07:00
Mark Hahnenberg c808438ee9 [client-sync] Transaction-ify processMessage
Summary:
We do lots of writes while processing a single message. To reduce the
write churn from lots of mini-transactions, this diff threads one
overarching transaction to everything in processMessage.

Test Plan: Run locally

Reviewers: spang, evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4394
2017-04-07 15:09:25 -07:00
Mark Hahnenberg b323e38f7c [client-sync] Increase sqlite page_size and cache_size
Summary:
The defaults are a little low. edgehill.db already does this. There's no
obvious effect on smaller dbs, but we should at least make the two
consistent.

Test Plan: Run locally

Reviewers: spang, evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4395
2017-04-07 13:08:13 -07:00
Juan Tejada 3befaf2d6e [client-app] Update changelog 2017-04-07 12:14:51 -07:00
Nylas Coffee Machine a30e63c91a bump(version): 2.0.8 2017-04-07 11:42:30 -07:00
Juan Tejada 763010326e [client-app] Ensure SyncbackMetadataTask dependency to prevent version conflicts
Summary:
Previously, SyncbackMetadataTasks for the same plugin did not depend on
each other, so they could try to modify the same piece of metadata
concurrently, which would likely produce version conflict errors.

This was happening with send reminders because we were queuing 2 of
these tasks back to back upn send success. Adding this dependency fixes
the version conflict errors when setting the metadata

Test Plan: manual

Reviewers: evan, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4393
2017-04-07 11:41:21 -07:00
Juan Tejada 17ade153f8 bump(version): 2.0.7 2017-04-06 19:32:30 -07:00
Karim Hamidou 01318370d4 [cloud-workers] [send-later] Fix send later token expiration
Summary:
Fixes T8076. So, the Gmail OAuth API returns us an expiration time in milliseconds, but we convert it to seconds everywhere, except in the cloud-api. This caused us to never refresh tokens because we'd be comparing seconds to milliseconds.

Fix this by converting the `expiry_date` from our credentials to seconds.

Test Plan: Tested manually. Will do more testing tomorrow, after my credentials expire.

Reviewers: evan, juan

Reviewed By: evan, juan

Maniphest Tasks: T8076

Differential Revision: https://phab.nylas.com/D4390
2017-04-06 18:57:16 -07:00
Evan Morikawa 236c71ea6a [iso-core, cloud-*] catch JSON parse errors in DB columns
Summary:
MySQL would insert bad JSON due to emoji errors. This would cause JSON
parse errors and prevent us from ever reading objects from the DB. We now
catch and return null instead with an error which will at least let the
query complete to let us isolate and deal with the malformed obeject (like
destroy it)

Test Plan: manual

Reviewers: spang, halla, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4389
2017-04-06 18:22:29 -07:00
Christine Spang d09312c27f [cloud-*] Switch MySQL charset to utf8mb4
Summary:
We need this in order to be able to store 4-byte emoji and other
extended unicode characters in the database.

Test Plan: deploy to staging - need the change that sets the connection charset on staging :(

Reviewers: khamidou, juan, evan

Reviewed By: juan, evan

Differential Revision: https://phab.nylas.com/D4387
2017-04-06 16:25:09 -07:00
Nylas Coffee Machine 3074ee2912 bump(version): 2.0.6 2017-04-06 16:12:23 -07:00
Juan Tejada 10d199f389 [dev] Ensure daily script grabs current version after pulling latest changes
Summary: see title

Test Plan: manual

Reviewers: halla, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D4378
2017-04-06 14:34:31 -07:00
Juan Tejada 5880f2ace7 [client-app] Always fetch and update identity regardless of env
Summary:
This was annoying because we wouldn't fetch the identity when running `local`
env which produced all sorts of errors

Test Plan: manual

Reviewers: evan, spang, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4380
2017-04-06 13:28:09 -07:00
Nylas Coffee Machine 50c0329591 bump(version): 2.0.5 2017-04-06 11:56:10 -07:00
Evan Morikawa 2ee67d2a7a [iso-core, cloud-*] move generate XOAuth2 & fix first auth usage
Summary:
We were not generating the XOAuth2 token on the first go when connecting
accounts. This would cause the first send later to fail. Since this
happens in ISO core, we needed to move the function out of cloud-core and
import from other places that use it

Test Plan: Manual

Reviewers: khamidou, juan, halla, spang

Reviewed By: spang

Differential Revision: https://phab.nylas.com/D4375
2017-04-06 11:53:39 -07:00
Juan Tejada 8633058488 [isomorphic-core] Ensure IMAPConnPool uses updated account credentials
Summary:
Previously, we would initialize an `AccountPool` with an account
instance and reference the account as an instance variable. Then,
every time we created a connection, we used the account we had a
reference to obtain the credentials.

However, if the credentials on the account changed, e.g. when we refresh
the access token for gmail accounts, the connection pool would never
realize that the account had new credentials and always try to create
the connection with the old credentials, causing the sync worker to
enter an error loop of `Invalid credentials` errors

To fix this, we could reload the account every time we try to create a
connection, but it seems that the fresh credentials should just be
passed every time we create connections without the pool having to be
aware of potential changes under the rug.

This commit makes it so the pool no longer holds a reference to the
account, but rather it is passed in every time we check out a connection

Test Plan: manual. how did this even work before? :(

Reviewers: evan, halla, spang, mark

Reviewed By: mark

Differential Revision: https://phab.nylas.com/D4370
2017-04-06 10:32:42 -07:00
Nylas Coffee Machine bb03d3c78e bump(version): 2.0.4 2017-04-05 17:54:09 -07:00
Nylas Coffee Machine 68b5550d54 bump(version): 2.0.3 2017-04-05 17:51:11 -07:00
Christine Spang cfe2971c2e [*] Revamp SSL options (including user-facing)
Summary:
Previously, the generic IMAP auth screen presented one security option to
users: "Require SSL". This was ambiguous and difficult to translate into
the correct security options behind the scenes, causing confusion and problems
connecting some accounts.

This patch does the following:
* Separates security settings for IMAP and SMTP, as these different protocols
  may also require different SSL/TLS settings

* Reworks the generic IMAP auth page to allow specifying security settings
  with higher fidelity. We looked at various different email apps and decided
  that the best solution to this problem was to allow more detailed
  specification of security settings and to ease the burden of more options
  by having sane defaults that work correctly in the majority of cases.
  This new screen allows users to pick from "SSL / TLS", "STARTTLS", or "none"
  for the security settings for a protocol, and also to instruct us that
  they're OK with us using known insecure SSL settings to connect to their
  server by checking a checkbox.

  We default to port 993 / SSL/TLS for IMAP and port 587 / STARTTLS for SMTP.
  These are the most common settings for providers these days and will work
  for most folks.

* Significantly tightens our default security. Now that we can allow folks to
  opt-in to bad security, by default we should protect folks as best we can.

* Removes some now-unnecessary jank like specifying the SSLv3 "cipher"
  in some custom SMTP configs. I don't think this was actually necessary
  as SSLv3 is a protocol and not a valid cipher, but these custom
  configs may have been necessary because of how the ssl_required flag was
  linked between IMAP and SMTP before (and thus to specify different
  settings for SMTP you'd have to override the SMTP config).

* Removes hard-coding of Gmail & Office365 settings in several
  locations. (This was a major headache while working on the patch.)

This depends on version 2.0.1 of imap-provider-settings, which has major
breaking changes from version 1.0. See commit for more info:
9851054f91

Among other things, I did a serious audit of the settings in this file and
"upgraded" a few servers which weren't using the SSL-enabled ports for their
provider to the secure ones. Hurray for nmap and openssl.

Test Plan: manual

Reviewers: evan, mark, juan, halla

Reviewed By: juan, halla

Differential Revision: https://phab.nylas.com/D4316
2017-04-05 17:49:43 -07:00
Halla Moore b5a19dd3e3 bump(version): 2.0.2 2017-04-05 16:04:42 -07:00
Evan Morikawa 4904a9ae85 [client-app] Updates to feature limiting
This is a squash of a bunch of commits releated to feature limiting.
Includes making the upgrade path seamless by accessing billing through a
WebView and making sure that the feature is enabled after upgrading, or
canceled if the upgrade path is stopped by the user in any way.

Included diffs
---------------
Differential Revision: https://phab.nylas.com/D4078
Differential Revision: https://phab.nylas.com/D4136
Differential Revision: https://phab.nylas.com/D4137
Differential Revision: https://phab.nylas.com/D4143
Differential Revision: https://phab.nylas.com/D4147
Differential Revision: https://phab.nylas.com/D4171
Differential Revision: https://phab.nylas.com/D4173
2017-04-05 16:02:53 -07:00
Mark Hahnenberg 965946724b [client-app] Some final benchmark fixes
Summary: See title

Test Plan: Run on the coffee machine

Reviewers: juan, evan, spang

Reviewed By: spang

Differential Revision: https://phab.nylas.com/D4368
2017-04-05 15:59:17 -07:00
Halla Moore d9a9d66f5f [client-sync] Fix syncWorker arg
Summary: It needs to be wrapped in an object.

Test Plan: manual

Reviewers: evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D4367
2017-04-05 15:44:13 -07:00
Juan Tejada fc7856b4d0 [client-sync] Fix runtime error when getting sync activity for account
Summary:
Make sure SyncActivity.getLastSyncActivityForAccount returns a sensible
default to prevent runtime errors when the SyncProcessManager uses it

Test Plan: manual

Reviewers: evan, halla

Reviewed By: halla

Differential Revision: https://phab.nylas.com/D4366
2017-04-05 14:10:01 -07:00
Nylas Coffee Machine 3653a66be2 bump(version): 2.0.1 2017-04-05 11:21:56 -07:00
Juan Tejada f708e3af0b [iso-core] IMAPConnectionPool now correctly disposes connections onDone
Summary:
Previously, calling the IMAPConnectionPool `onDone` callback when checking out a connection would just return the connection to the pool without re-establishing it the next time we checked it out of the pool.

When the `onDone` callback was called in an error scenario, this had the unintended consequence of returning a bad connection to the pool, and then re-using this bad connection. The only scenario when the connection was re-established was if `onConnected` threw an error, but if the connection was kept open outside the scope of onConnected, this logic would never run.

To make things simpler and more consistent, `onDone` will always destroy all connections and connections will always be re-established from scratch every time they are checked out of the pool. The pool acts more as a limit to the number of connections per account, than an actual shared pool of connections.

Test Plan: manual

Reviewers: evan, spang, halla, mark

Reviewed By: halla, mark

Differential Revision: https://phab.nylas.com/D4360
2017-04-05 11:10:41 -07:00
Juan Tejada 5269c11ee0 [client-sync] Prevent IMAP connection leaking in sync worker
Summary:
When the sync worker got stuck inside `performSync`, we would never
release the connection back to the connection pool. We would then try to
start a new sync worker, and it would claim a new connection. If this
happened enough times, we would eventually exhaust the whole pool and
keep the sync worker blocked forever.

Test Plan: manual

Reviewers: evan, spang, halla, mark

Reviewed By: halla, mark

Differential Revision: https://phab.nylas.com/D4359
2017-04-05 11:08:20 -07:00