Commit graph

17 commits

Author SHA1 Message Date
Evan Morikawa f2517ea7d7 refactor(name): rename worker-sync package to deltas
Summary:
This diff is a rename. No logical changes.

We used to have a set of files called `nylas-sync-worker`. In Old N1 these
used to have a lot of logic to slowly sync mail from our API. Since we
exclusively use local-sync via a soon-to-be-obsolesced delta stream, these
files really just manage the delta streaming connection.

It's incredibly confusing to have a set of files called worker-sync when
there's a sync-worker already in the codebase. This renames everything to
refer to them as account sync workers.

The reason I wanted this rename is because the IdentityStore on initial
launch triggers and fires a fairly scary-sounding
`Actions.refreshAllSyncWorkers()`. In reality all it does is
`Actions.refreshAllDeltaConnections()`. I'm also tired of staring at files
for a full minute before realizing that this is not the sync worker I was
  looking for.

Test Plan:
After rename, booted the app and ensured that deltas were coming through
for new mail and no errors were being thrown

Reviewers: halla, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3767
2017-01-25 10:08:23 -05:00
Juan Tejada b1882656ee fix(deltas) Prevent app from crashing when processing deltas
Summary:
Some strange scenario is causing us to attempt to redefine the object property `_delta` on our `delta.attributes` object inside `DeltaProcessor._decorateDeltas`, which throws an error, and consequently throws the app into an error loop. I haven't been able to track down how to reproduce this, but when it happens it completely takes the app down.

From testing with tomasz's copy of N1, this seemed to have originated from the lack of Account tokens, which was hard to discover because the `_deltas` object completely floods the console with errors.

From what I gather, `_decorateDeltas` is only called from a single place, `DeltaProcessor.process`, which is also only called from a single place, and its unclear how it would be called multiple times with the same delta object references.

In order to prevent this error from completely destroying the app, I've added the `configurable` option when defining the property, so that redifining it doesn't throw an error. It should be safe to redefine this property with the latest delta reference, and will also allow us to discover other errors more easily in the console like the lack of account tokens which might be the original cause of this problem.

Test Plan: manual

Reviewers: mark, spang, evan, halla

Reviewed By: evan, halla

Differential Revision: https://phab.nylas.com/D3717
2017-01-16 19:37:37 -08:00
Evan Morikawa 5a2a52ebab perf(sync): don't send message bodies across IPC & limit global IPC
Summary: don't send unnecessary crap over IPC

Test Plan: manual

Reviewers: spang, mark, juan, halla

Reviewed By: juan, halla

Differential Revision: https://phab.nylas.com/D3705
2017-01-16 10:28:49 -08:00
Halla Moore 9066078911 fix(delta-processor): Return created models in the expected format
Summary:
We were returning an array of arrays, when really we wanted an object
of arrays keyed by model type. This also involved removing an implementation
of mapObject that was overwriting underscore's implementation of it.

Test Plan: local, having others try it.

Reviewers: juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3509
2016-12-15 12:12:37 -08:00
Juan Tejada 9039c49dba fix(send/tasks): Fix deltas for SyncbackRequest SyncbackTaskAPIRequest
Summary:
This commit fixes processing deltas for `ProviderSyncbackRequests` and
resolution of the `SyncbackTaskAPIRequest`

Specifically:
- Fix and update field definitions for `ProviderSyncbackRequest`
- Correctly parse the error attached to any `ProviderSyncbackRequest`
- Correctly process deltas for `ProviderSyncbackRequests` inside the
delta-processor
- Fix any tasks that used `SyncbackTaskAPIRequest`, and update send to use those

Depends on D3510

Test Plan: Todo/Manual

Reviewers: jackie, halla, evan

Reviewed By: halla, evan

Differential Revision: https://phab.nylas.com/D3511
2016-12-15 11:57:14 -08:00
Juan Tejada 68e596bdf4 [local-sync] Correctly sync folders and labels
This commit will correctly keep track of folder and label ids when
creating them from N1.

Previously, when we sent the request to create a folder or label to our api,
we would immediately get back a serverId because it was created optimistically
in the back end— given that K2 is strictly non-optimistic, we won’t have a serverId
until some undetermined time in the future, and we need to somehow reference
the object that /was/ optimistically created in N1 to update the ui when
we do get the server id.

Since we can deterministically generate ids for folders and labels,
we "guess" what its going to be, and include it in the props of the syncback request
returned to N1. This is the simplest solution to get thing working
correctly right now, but we’ll need to revisit this in the future for
other types of objects (drafts, contacts, events), and revisit how we
will manage optimistic updates in N1 when we merge the 2 codebases
with K2 (given that K2 was designed to be non-optimisitc).
2016-12-05 18:57:13 -08:00
Ben Gotow b0b231094d fix(deltas): Minor tweaks to metadata delta processing 2016-12-05 10:19:37 -08:00
Ben Gotow a9ccd7370c fix(deltas): Minor adjustments for thread deltas 2016-12-02 15:59:05 -08:00
Jackie Luo ad5a1a6316 refactor(nylas-api): Make requests with helpers 2016-12-02 15:51:38 -08:00
Ben Gotow 0e8829b929 fix linter errors 2016-12-02 15:44:52 -08:00
Christine Spang a1a85e04be feat(metadata): Look up local thread IDs via message table when setting metadata
Since message IDs are now static but there's no good way to generate
static thread IDs while syncing an account from newest message first,
we give threads the ID of any message on that thread and, when setting
metadata, look up the local thread ID by first going through the
message table.
2016-12-02 14:13:58 -08:00
Evan Morikawa cee7d05017 debug(delta): add logs 2016-12-02 15:11:48 -05:00
Ben Gotow fb13abe8f4 fix(deltas): Process all deltas of each class in a single pass
Also changed the DeltaProcessor so it doesn’t query for models before sending out `Actions.didPassivelyReceiveCreateDeltas`, and renames it to be more clear it’s about deltas.
2016-12-02 11:41:49 -08:00
Juan Tejada d409a5a3f9 fix(delats): Warn when receiving unkown obejct class 2016-12-01 09:14:02 -08:00
Ben Gotow ed74e454d2 fix(deltas): Fix deltaProcessor handling deletes wrong 2016-11-30 17:00:11 -08:00
Ben Gotow daed7146b5 fix(deltas): Delta.id is now a transaction id, need objectId 2016-11-30 16:53:52 -08:00
Evan Morikawa 5582782ddd refactor(delta): add a second delta stream, convert to es6, and cleanup
This reverts commit ee5609bdb0.

Updates to nylas sync worker to support multiple cursors

Convert NylasSyncWorker to es6

Convert NylasSyncWorkerPool to es6

Extract into deltaProcessor

Update names to NylasSyncWorker state

Working on spec fixes

More spec fixes

Delta stream refactor fixes
2016-11-30 13:42:10 -05:00