Commit graph

5520 commits

Author SHA1 Message Date
Evan Morikawa 222b486082 bump(k2): adding accountId index 2017-02-14 10:49:18 -08:00
Evan Morikawa 4245ec7aa5 [isomorphic-core] add accountId index definition to Transaction table 2017-02-14 10:48:12 -08:00
Evan Morikawa 2825a3553e fix(delta): report error when delta gets invalid cursor 2017-02-14 10:46:53 -08:00
Evan Morikawa f07be909f4 fix(spec): re-enable DatabaseStore specs
Summary:
Re-enable DatabaseStore specs and use new async model that awaits for the
promises to resolve

Test Plan: new tests

Reviewers: spang, halla, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3909
2017-02-14 09:07:40 -08:00
Evan Morikawa 35807ad7d0 fix(db): wait for models to be setup before activating packages
Summary:
Some plugins (like the Salesforce Plugin) register Models with the
database store. Upon plugin load, we check to see if there are newly
registered models, if there are, we try and refresh the database.

Unfortunately the database refresh was not being `await`ed for. This means
the `activate` method of the plugin was called before the models were
created creating DB errors.

Making `refreshDatabaseSchema` something you can `await` for requied
adding an async ready hook on the DatabaseStore itself that will work in
all windows, even though setup is only happening in one window.

Test Plan:
Turn DatabaseStore.DEBUG_TO_LOG = true and run before and after the patch
with SFDC enabled. See that after the patch the DB setup happens before
activate gets called

Reviewers: halla, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3906
2017-02-14 09:03:57 -08:00
Boris Kaiser a5501b57ef Fix broken link (#3284) 2017-02-13 21:53:57 -08:00
Juan Tejada fe57a5884b [local-sync] 🎨 comment 2017-02-13 21:52:21 -08:00
Juan Tejada e441553b50 [local-sync] syncback(Part 5): Always keep retrying tasks if error is retryable
Summary:
This commit makes it so we always continue retrying syncback tasks as long as they
error with a retryable error. There's really no reason to not continue retrying syncback
tasks after an arbitrary number of retries (especially such a low one) if we
encounter a retryable error. Before this commit, if for example we got 2 random
network errors in a row, we would just mark the task as failed even
though it would eventually succeed in subsequent attempts.

Previously, when N1 synced against the cloud api, we would indefinitely
retry a Task if we continued getting retryable errors. This ensures that
the app can work correctly offline and prevents displaying unecessary errors to
the user, and having actions bouncing back or sending messages without putting them
in the sent folder.

Additionally, this commit ensures that when cleaning up messages without a
folderImapUID we don't delete messages that are currently being added to the sent
folder. This is relevant to this commit because given that we could retry the
EnsureMessageInSentFolder task indefinitely, we might end up deleting that
message because it wont have a uid until the task succeeds.

Depends on D3898

Test Plan: manual

Reviewers: mark, spang, evan, halla

Reviewed By: spang, evan, halla

Differential Revision: https://phab.nylas.com/D3900
2017-02-13 21:50:02 -08:00
Juan Tejada fe46278390 fix(account) Properly keep tokens in sync between acct stores in different windows
Summary:
When loading accounts, if we detect any removed accounts, we should get
rid of the tokens for that account as well.

Test Plan: manually removed accounts, everything seems a-ok

Reviewers: mark, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D3907
2017-02-13 21:40:18 -08:00
Christine Spang 3854051350 [local-sync] 🔥 Message syncback tasks
Summary:
Since all Nylas Mail actions are thread-based except for sending,
we never use any of these. Make `git grep` less confusing by getting rid
of them.

Test Plan: use the app

Reviewers: evan, halla, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3910
2017-02-13 18:27:18 -08:00
Juan Tejada b0e21b5381 fix(accounts) Don't report error when removing accounts
Summary:
The current error condition check is to make sure that accounts are exclusively
removed via `Actions.removeAccount`. However, when removing accounts,
the in-memory `AccoutStore`s in each window are kept in sync via listening
to the config, as opposed to dispatching Actions globally between windows
(Actions.removeAccount is scoped to a single window, see actions.es6).
So, when we remove an account in one window, config.json will change, and the
other windows will always encounter `removedIds.length > 0` to be true
when their `_loadAccounts` runs. This will only generate unecessary noise in Sentry.

Test Plan: manual

Reviewers: mark, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D3902
2017-02-13 15:13:26 -08:00
Juan Tejada 964bc3208f [local-sync] syncback(Part 4): Don't always mark INPROGRESS tasks as failed at beginning of sync
Summary:
Previously, if you were to close the app while you had any tasks queued,
these would be marked as failed the next time you open the app, showing
an annoying error message and reverting any optimisitic actions.

However, we don't need to be so defensive about retrying tasks because
the only tasks we can't retry are the Sending tasks. All of the other
tasks like moving or changing labels are fine to retry (trying  move the same
set of uids twice wont cause an error)

This commit adds an extra status to syncback requests, "NOTRETRYABLE".
Only NOTRETRYABLE requests will be marked as failed at the beginning of
the sync loop, and any INPROGRESS tasks will be marked as NEW so they
can be retried

Depends on D3896

Test Plan: manual

Reviewers: mark, evan, spang, halla

Reviewed By: evan, halla

Differential Revision: https://phab.nylas.com/D3898
2017-02-13 13:48:29 -08:00
Halla Moore a49f5b4a7d fix(tests): Fix some tests and add tests for thread metadata
Summary: Depends on D3875

Test Plan: run the tests

Reviewers: juan, evan

Reviewed By: juan, evan

Differential Revision: https://phab.nylas.com/D3876
2017-02-13 13:11:10 -08:00
Halla Moore 667afa2012 fix(metadata): Fix some issues with processing metadata deltas
Summary:
- Create ghost models if we receive metadata for an object we
    haven't synced yet
- Fix logic for finding equivalent threads
- Send `messageIds` when syncing thread metadata

See D3876 for unit tests

K2 pairing: D3880

Test Plan: unit tests, local testing soon

Reviewers: juan, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D3875
2017-02-13 13:10:38 -08:00
Juan Tejada 20374b4e9d bump k2 2017-02-13 13:08:34 -08:00
Juan Tejada 4e85993957 [local-sync] syncback(Part 3): Fixup runSyncbackTasks
Summary:
Now that we don't run Send tasks outside the sync loop, we don't need
that awful hack wich required passing a `runTask` callback to
`runSyncbackTask` in order to customize how to run the task.

Instead, runSyncbackTask now knows 2 ways to run a task, either via imap, or
via smtp, depending on the resource declared by task to run. So now
SyncbackTasks declare a resource type they need to run, and that will be
passed as their second argument when running.

Depends D3894

Test Plan: manual

Reviewers: mark, halla, spang, evan

Reviewed By: halla, spang, evan

Differential Revision: https://phab.nylas.com/D3896
2017-02-13 13:07:20 -08:00
Juan Tejada c1ecd045d7 [local-sync] syncback(Part 2): Reinstate send tasks back into the sync loop
Summary:
We had previously ripped send tasks outside the sync loop to make them run faster,
but they run fast enough inside the loop.

This commit will also fix the scenario where if you closed the app in the
middle of a send task, the task would just hang forever and never succeed or
fail (T7818); given that it was excluded from the loop, we also had to exclude it
from the cleanup step to mark any INPROGRESS tasks as failed at the beginning
of each loop, which caused send tasks in progress to never get cleaned.

Putting them back inside the loop allows us to  fix this without adding more messy
logic, and it cleans up ugly duplicated code. Additionally, it will prevent more
duplicated code for upcoming diffs that will improve syncback task reliability
when the app is closed or window is restarted in the middle of a task.

Depends on D3893

Test Plan:
manually test sending, it still works, it's still fast. Restarted
window in the middle of send task, task fails.

Reviewers: mark, spang, halla, evan

Reviewed By: spang, halla, evan

Differential Revision: https://phab.nylas.com/D3894
2017-02-13 13:05:11 -08:00
Halla Moore 8287f4116f [local-sync, cloud-api] Add logic to handle thread metadata
Summary:
[cloud-api]
Based on the passed in `messageIds`, it finds any existing thread
metadata that might be under a different thread id. If it realizes
there are actually multiple threads that should be the same thread,
(due to getting a missing message link), it reconciles all of them.

[local-sync]
Return `message_ids` in `Thread.toJSON()`

See D3879 for tests

N1 Pairing: D3875

Test Plan: unit tests, local testing soon

Reviewers: juan, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D3880
2017-02-13 13:02:40 -08:00
Juan Tejada 1e74be3b94 [local-sync] syncback(Part 1): Refactor syncback-task-helpers
Summary:
Instead of exposing helper functions, make this a class to hold the
shared state of the db, account, and logger required to run any syncback
inside an account sync loop.

Test Plan: manual

Reviewers: mark, spang, halla, evan

Reviewed By: spang, halla, evan

Differential Revision: https://phab.nylas.com/D3893
2017-02-13 13:01:28 -08:00
Juan Tejada f09eec711c fix(send) Add better error checking when sending message
Summary:
See title.
I believe this might fix T7559, or at least provide a better error message.

Depends on D3895

Test Plan: manual

Reviewers: spang, mark, halla, evan

Reviewed By: mark, halla, evan

Maniphest Tasks: T7559

Differential Revision: https://phab.nylas.com/D3897
2017-02-13 12:36:53 -08:00
Juan Tejada 1ea9853d12 fix(send): Correctly wait for send task to complete before succeeding!
Summary:
If the worker window were to restart or the app were to close in the
middle of a send task, sending to a single recipient, we would not
properly await the task and always mark as success.

This diff, along with (D3897) should fix T7559.

Test Plan: manual

Reviewers: spang, mark, evan, halla

Reviewed By: mark, evan, halla

Maniphest Tasks: T7559

Differential Revision: https://phab.nylas.com/D3895
2017-02-13 12:31:40 -08:00
Juan Tejada 8d875a6307 fix(offline-notif) Try to connect immediately upon window focus
Summary: see title

Test Plan: manual

Reviewers: mark

Reviewed By: mark

Differential Revision: https://phab.nylas.com/D3901
2017-02-13 12:23:31 -08:00
Juan Tejada 06fe77bb21 bump k2 2017-02-13 12:21:16 -08:00
Juan Tejada dbb404ccba [iso-core] Detect more offline errors when sending
Summary:
See title.
I really wish we could clean up this error handling a bit better, but I don't
think its super important right now.

Test Plan: manual

Reviewers: spang, evan, halla

Reviewed By: evan, halla

Differential Revision: https://phab.nylas.com/D3903
2017-02-13 12:18:45 -08:00
Christine Spang e71fb04bd8 feat(specs): Add support for generating JUnit XML by passing --junit-xml=<path>
Summary:
A prerequesite to integrating with `arc unit` or CI for each patchset is
being able to generate JUnit XML output for spec runs. This commit adds
this feature using the JUnitXMLReporter from jasmine-reporters. Invoke it like
this:

    npm run test-junit

(We output to the terminal as well when this is run, so in the case that
you're doing `arc diff` you have some idea of what is going on.)

Test Plan: run it

Reviewers: halla, juan, evan

Reviewed By: juan, evan

Differential Revision: https://phab.nylas.com/D3891
2017-02-13 12:05:52 -08:00
Juan Tejada 85dc9f319e [local-sync] Add a better reason when waking sync for syncback
Summary: see title

Test Plan: nil

Reviewers: mark

Reviewed By: mark

Differential Revision: https://phab.nylas.com/D3892
2017-02-13 12:00:13 -08:00
Christine Spang d6a234e94a 🎨 s/N1/Nylas Mail/ in window-event-handler.coffee 2017-02-13 11:14:41 -08:00
Juan Tejada b984a27482 bump k2 2017-02-11 15:30:43 -08:00
Juan Tejada a5e6fae063 fix(syncback-category) Return error when task fails 2017-02-11 13:03:56 -08:00
Juan Tejada 3a2f2ec6fc [local-sync] More retryable IMAP errors
Summary:
I've encountered random imap errors that we mark as permanent, but that
contain try again in the error message. We should check for that

Test Plan: manual

Reviewers: spang, evan, mark

Differential Revision: https://phab.nylas.com/D3899
2017-02-11 12:56:35 -08:00
Juan Tejada 81208062c0 fix(specs) Correctly set configDirPath when running tests
Before this commit, running the running the tests would clear all of
your config inside `.nylas-dev` and thus your accounts, forcing you to re-add
them everytime after you ran the tests

This was happening because we weren't correctly setting the
`configDirPath` to `.nylas-spec` when running with the --test flag. When
we run with --test, both options, `specMode` and `devMode` are true, so
the logic to set the path would fall into both conditions and ultimately
set the path to `.nylas-dev`. Now it's fixed!
2017-02-10 19:16:53 -08:00
Juan Tejada f4dbd555d1 fix(specs) 🔪 more side-effect flakiness 2017-02-10 19:01:17 -08:00
Juan Tejada d89887c20f fix(specs) Fix FeatureUsageStore spec flakiness 2017-02-10 16:48:06 -08:00
Evan Morikawa af6074f6f5 bump(changelog): 1.0.26 2017-02-10 18:43:51 -05:00
Evan Morikawa e92b668a1e bump(version): 1.0.26 2017-02-10 18:41:20 -05:00
Evan Morikawa 6f64e2f762 bump(changelog): 1.0.26 2017-02-10 18:41:20 -05:00
Halla Moore f86ff97062 fix(n1-spec-runner): Make fit async too
Summary: Running async tests with `fit` can fail otherwise

Test Plan: unit tests

Reviewers: juan, evan

Reviewed By: juan, evan

Differential Revision: https://phab.nylas.com/D3874
2017-02-10 15:41:07 -08:00
Halla Moore 0e5aebb91d fix(tests): Allow the masterBefore/AfterEach functions to be async
Summary:
The global `before/afterEach` functions were made async, but the
`masterBefore/AfterEach` functions were applied to the references
in `jasmineExports` instead of the global references. Fix that,
and await for `destroyTestDatabase()`. Also fix a random test
failure about not receiving any json.

This diff is necessary for D3878 to work properly.

Test Plan: ran the tests

Reviewers: juan, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D3890
2017-02-10 15:38:55 -08:00
Halla Moore 2d3bb52bc8 [local-sync] Properly clean-up in-memory test database
Summary: There's no file to unlink, we just need to drop the tables.

Test Plan: manual

Reviewers: evan, juan

Reviewed By: evan, juan

Differential Revision: https://phab.nylas.com/D3878
2017-02-10 15:37:58 -08:00
Evan Morikawa 614992f550 bump(k2) 2017-02-10 18:21:06 -05:00
Evan Morikawa e646d56bf8 [local-sync] fix sync when no messages in inbox in gmail
Summary:
If you have no messages in your Gmail Inbox (Yay Inbox Zero!) and you
connect your account and do first sync, then we get an error where we try
and fetch a range from null to -1.

This was due to a logical error in the first sync fetch code.

This diff fixes this bug and renames some variables to make it clearer
what's going on

Fixes T7842

{F11176}

Test Plan:
1. Bring Gmail to Inbox Zero
2. Connect account
3. Verify first sync works

Reviewers: spang, halla, juan

Reviewed By: juan

Maniphest Tasks: T7842

Differential Revision: https://phab.nylas.com/D3889
2017-02-10 18:20:53 -05:00
Juan Tejada 8d36ce6723 Actually fix travis 2017-02-10 15:16:07 -08:00
Juan Tejada d558990ecf fix(build) Fix travis build script 2017-02-10 15:11:43 -08:00
Juan Tejada cab1acfcc9 fix(build/travis) Only run tests on mac 2017-02-10 15:01:50 -08:00
Evan Morikawa f33667e1a1 fix(specs): fix FeatureUsage spec
Summary: Damn async TaskQueue

Test Plan: fixed

Reviewers: juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3888
2017-02-10 16:49:40 -05:00
Mark Hahnenberg 9c3dd29c10 [files] Add retry with exponential backoff for file downloads in NM
Summary: See diff title

Test Plan: Run locally, verify that we backoff on failure

Reviewers: evan, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3887
2017-02-10 13:47:21 -08:00
Mark Hahnenberg 8f08328329 [files] Add retry with exp backoff to IMAP connections for file download requests
Summary: See diff title

Test Plan: Run locally, make sure we backoff

Reviewers: juan, spang, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D3886
2017-02-10 13:29:12 -08:00
Evan Morikawa 31ae05fed2 fix(identity): remove the savePromise and optimistically update
Summary:
Fixes T7832

The _savePromise mechanism of the IdentityStore was really cumbersome and
was throwing errors on the console for people. In hindsight, this is an
unnecessary complication to a very sensitive system and a source of very
hairy async bugs.

Test Plan:
I also updated the specs to ensure that when you call saveIdentity the
promise resolves after the local cache has been updated

Reviewers: spang, halla, juan

Reviewed By: juan

Maniphest Tasks: T7832

Differential Revision: https://phab.nylas.com/D3882
2017-02-10 15:52:57 -05:00
Evan Morikawa 8a18ac3e14 fix(load): fix window load timing
Summary:
The app regressed to launching a blank white page for a while before
showing the UI. This was because I forgot to await for the now async
package loading

Test Plan: Manually boot app with compile cache disabled

Reviewers: mark, spang, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3883
2017-02-10 15:52:40 -05:00
Juan Tejada 3a49bfe448 fix(specs) Fix Spellchecker tests
Summary:
Previously, these tests were mostly testing the library itself, instead
of our code. The library performed expensive operations and caused the
test to time out more often than not

This commit makes it so we test our code, mock out any calls to side
effects, and removes a line that was overriding our jasmine timeout

Test Plan: unit

Reviewers: spang, evan, halla

Reviewed By: evan, halla

Differential Revision: https://phab.nylas.com/D3885
2017-02-10 12:36:07 -08:00