Commit graph

85 commits

Author SHA1 Message Date
Evan Morikawa 278a4d16d4 fix(spec): progress on spec fixes for sync worker 2016-12-01 13:17:55 -05:00
Juan Tejada d409a5a3f9 fix(delats): Warn when receiving unkown obejct class 2016-12-01 09:14:02 -08:00
Evan Morikawa 380f370e7d fix(sync): Support N1Cloud auth errors. Fix LongConnection cleanup 2016-12-01 12:04:37 -05:00
Evan Morikawa 58874e8ad3 fix(delta): JSON blob persist failed to save properly 2016-12-01 11:04:19 -05: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
Juan Tejada dfee7ea9b6 fix(k2) fix local sync deltas 2016-11-30 16:13:26 -08:00
Evan Morikawa 3a72987f4d fix(delta): default cursor to 0 if no transactions exist yet 2016-11-30 17:56:59 -05:00
Evan Morikawa 3d4035ac64 fix(delta): fix issues with delta sync 2016-11-30 17:55:45 -05: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
Jackie Luo 7b7fbb3b1b refactor(nylas-api): Create API requests from tasks 2016-11-29 16:33:44 -08:00
Ben Gotow 848feaad60 fix(sync-worker): Missing binding arrow… 2016-11-29 12:44:02 -08:00
Juan Tejada 0b5f2841d5 fix(deltas) Update syncworker signature 2016-11-29 12:39:36 -08:00
Evan Morikawa ee5609bdb0 Rename DeltaStreamingConnection -> LocalDeltaSyncConnection 2016-11-28 17:13:18 -08:00
Evan Morikawa caba64d39d Update nylas-sync-worker to better fetch metadata 2016-11-28 16:59:04 -08:00
Evan Morikawa 9cbc284ed5 Fetch folders and labels at the same time 2016-11-28 16:11:10 -08:00
Ben Gotow 864766d463 fix(sync): Throttle instead of debounce for better initial sync 2016-11-28 12:05:41 -08:00
Halla Moore f4357ce166 change(API) Prevent N1 from sending "view" parameters in some API requests
- Threads: N1 always asks for the 'expanded' view, so K2 just always returns
the expanded view. N1 no longer needs to specify this.
- Messages: N1 only needed a 'count' view to display the initial sync progress
We've removed this progress bar and the corresponding request.
2016-11-21 15:16:04 -08:00
Ben Gotow 80b315d708 deps(*): Lift deps out of packages for simpler install / better deduping 2016-11-09 14:24:10 -08:00
Mark Hahnenberg dde4738363 Fix broken test
Summary:
Fixes a test that was broken due to my unfamiliarity with
CoffeeScript :-/

Test Plan: Tests

Reviewers: bengotow

Reviewed By: bengotow

Subscribers: juan

Differential Revision: https://phab.nylas.com/D3302
2016-09-26 16:49:22 -07:00
Mark Hahnenberg 0319528988 Add jitter to BackoffTimer
Summary:
This should help us avoid the thundering herd problem if we have some
kind of API outage affecting a wide number of clients.

Test Plan: Tests

Reviewers: bengotow

Reviewed By: bengotow

Subscribers: juan

Differential Revision: https://phab.nylas.com/D3297
2016-09-26 13:36:49 -07:00
Juan Tejada 3dccb374b3 fix(search/long-conn): Process results buffer before ending connection (#750)
NylasLongConnection ends the connection when the 'end' event is emitted
by the `request` object. When this happens, the global connection buffer is cleared.
Also, the global buffer holds the data we've received from the connection, and
whenever we receive new data, we accumulate it in the buffer and call a processBuffer function
which is throttled to 400ms.

Given that the buffer is global state, and processing occurs
asynchronously with a delay of up to 400ms, if the 'end' event on the connection is
fired before we actually get to process the buffer, we would clear it and show no results.

This scenario currently only affected search because if we accidentally
threw away some data when streaming deltas, we will get that data again
when we reopen the delta streaming connection.
2016-09-22 12:08:59 -07:00
Juan Tejada 7dadf2ccd3 fix(specs): Properly spy on streaming connection
- Prevent error logs and actually trying to start delta streaming
connections
2016-07-28 12:40:31 -07:00
Juan Tejada fb18299bc2 fix(log): Rm unecessary console.log call 2016-07-28 10:31:48 -07:00
Juan Tejada 4427f5eda1 fix(deltas): Update latest cursor, address comments
- Add test to make sure that latest cursor is updated
2016-07-27 14:30:12 -07:00
Juan Tejada aaeda2e5ac fix(deltas): Consolidate nylas-long-connection code
- Completely remove nylas-long-connection.coffee file and consolidate all logic into
nylas-long-connection.es6 and worker-sync/delta-streaming-connection.es6:
  - Separate it into DeltaStreamingConnection which is specific to the worker-sync
    package for handling deltas
  - NylasLongConnection is a "reusable" persistent connection to our API
    which is also used by the search package
  - This is a basically a fixed revision of https://phab.nylas.com/D2875,
    see difff for more info
- Makes it so delta streaming does not retry so aggressively on 403s, which
  happens whenever a user’s trial has expired
2016-07-27 02:56:55 -07:00
Ben Gotow 3f6415c119 fix(specs): Misc fixes 2016-07-20 12:33:52 -07:00
Evan Morikawa 27bfd91e32 fix(delta): add N1 token to delta stream connection 2016-07-13 22:02:48 -07:00
Carson Ip a3874ce1de Fix incorrect port number when using https (#2600)
When APIRoot is using https, the port will forced to be 443 even when APIRoot
indicates another port. This is because of the line options.port = 443
overwriting the correct options.port extracted by url.parse. This is fixed by
removing the problematic line. The default port is still 443 if you look into
https.js. In case we want a different default port in the future, we can do
options.port = options.port || 443.
2016-07-12 12:03:13 -07:00
Evan Morikawa c4753197ee fix(analytics): improved analytics 2016-06-07 13:38:47 -07:00
Ben Gotow 508c92f599 fix(sync): Always restart where left off after initial sync interrupted 2016-06-02 18:56:09 -07:00
Ben Gotow 0c77f61838 fix(config): removeAtKeyPath => undo, guard with assertions 2016-05-25 14:03:09 -07:00
Ben Gotow 345d006533 fix(connection): account.id => accountId 2016-05-16 03:26:23 -05:00
Ben Gotow b3b6276f4e Revert "refactor(deltas): Update sync-worker to use NylasAPI.longConnection"
This reverts commit 1a78a758f4.

# Conflicts:
#	internal_packages/worker-sync/lib/delta-streaming-connection.es6
#	internal_packages/worker-sync/lib/nylas-sync-worker.coffee
#	internal_packages/worker-sync/spec/nylas-sync-worker-spec.coffee
#	src/flux/nylas-long-connection.es6
2016-05-16 01:25:30 -05:00
Juan Tejada c564b2c0f7 fix(delta-streaming): Fix stale cursor key in config file 2016-05-11 10:34:29 -07:00
Evan Morikawa 1498bcfac6 fix(lint): final linter fixes
fix(lint): final set of linter fixes
2016-05-06 16:32:34 -07:00
Evan Morikawa 7f50074c0d feat(babel6): Convert to use new es6 require syntax 2016-05-06 11:54:55 -07:00
Juan Tejada 1a78a758f4 refactor(deltas): Update sync-worker to use NylasAPI.longConnection
Summary:
- Remove nylas-long-connection.coffee duplicate code from sync worker package
  and replace with delta-streaming-connection which uses NylasAPI.longConnection
- Replacement for XHR will come in another diff -- still need to clean up and
  fix some edge cases

Test Plan:
- TODO! Will add test coverage for NylasLongConnection and
  DeltaStreamingConnection

Reviewers: evan, bengotow

Reviewed By: evan, bengotow

Differential Revision: https://phab.nylas.com/D2875
2016-05-04 13:03:47 -07:00
Juan Tejada 8ff5f4f8b5 fix(cursor): Remove stale cursor from config.cson when cursor error
- #2049
2016-04-28 10:16:40 -07:00
Evan Morikawa 78112563a6 feat(win): faster popout windows
Summary:
This diff is designed to dramatically speed up new window load time for
all window types and reduce memory consumption of our hot windows.

Before this diff, windows loaded in ~3 seconds. They now boot in a couple
hundred milliseconds without requiring to keep hot windows around for
each and every type of popout window we want to load quickly.

One of the largest bottlenecks was the `require`ing and initializing of
everything in `NylasExports`.

I changed `NylasExports` to be entirely lazily-loaded. Drafts and tasks
now register their constructors with a `StoreRegistry` and the
`TaskRegistry`. This lets us explicitly choose a time to activate these
stores in the window initalization instead of whenever nylas-exports
happens to be required first.

Before, NylasExports was required first when components were first
rendering. This made initial render extremely slow and made the proposed
time picker popout slow.

By moving require into the very initial window boot, we can create a new
scheme of hot windows that are "half loaded". All of the expensive
require-ing and store initialization is done. All we need to do is
activate the packages for just the one window.

This means that the hot window scheme needs to fundamentally change from
have fully pre-loaded windows, to having half-loaded empty hot windows
that can get their window props overridden again.

This led to a major refactor of the WindowManager to support this new
window scheme.

Along the way the API of WindowManager was significantly simplifed.
Instead of a bunch of special-cased windows, there are now consistent
interfaces to get and `ensure` windows are created and displayed. This
DRYed up a lot of repeated logic around showing or creating core windows.

This also allowed the consolidation of the core window configurations into
one place for much easier reasoning about what's getting booted up.

When a hot window goes "live" and gets populated, we simply change the
`windowType`. This now re-triggers the loading of all of the packages for
the window. All of the loading time is now just for the packages that
window requires since core Nylas is there thanks to the hot window
mechanism.

Unfortunately loading all of the packages for the composer was still
unnaceptably slow. The major issue was that all of the composer plugins
were taking a long time to process and initialize. The solution was to
have the main composer load first, then trigger another window load
settings change to change the `windowType` that loads in all of the
plugins.

Another major bottleneck was the `RetinaImg` name lookup on disk. This
requires traversing the entire static folder synchronously on boot. This
is now done once when the main window loads and saved in a cache in the
browser process. Any secondary windows simply ask the backend for this
cache and save the filesystem access time.

The Paper Doc below is the current set of manual tests I'm doing to make
sure no window interactions (there are a lot of them!) regressed.

Test Plan: https://paper.dropbox.com/doc/Window-Refactor-UYsgvjgdXgVlTw8nXTr9h

Reviewers: juan, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2916
2016-04-22 13:30:42 -07:00
Kevin Jose Martin 78ea5c0c64 Doing write on a GET is invalid. (#2004)
* Doing write on a GET is invalid

* Doing write on a GET is invalid
2016-04-20 10:07:12 -07:00
Ben Gotow 046c8b3122 fix(sync): Handle "Invalid cursor" scenario by 💣🔥 away the cache 2016-04-11 17:34:52 -07:00
Ben Gotow d884eccb36 fix(specs): * 2016-04-08 16:03:21 -07:00
Ben Gotow 227bc81736 fix(sync-errors): Improve display of sync errors and offline status
- Make the retry interval go 2 sec, 3.4s, 6 sec...
- Only show the connection status bar if the interval is > 5 seconds, in case the error was temporary.
- Do not show sync errors in the sidebar. The only available action is "Try Again", and we try again on our own. The error is frustrating and the user can't do anything about it anyway.
2016-04-08 13:52:26 -07:00
Juan Tejada 9f4b9693ac fix(sync-status): Fix logic for checking sync status:
- Only check sync status keys that belong to actual models being synced
- Return false if state object is empty
2016-04-05 13:29:25 -07:00
Juan Tejada fc489e5db3 feat(thread-search): Add client side search
Summary:
This diff includes several updates:
- Update sqlite version to use FTS5
- Adds new methods to DatabaseStore to create and update Search Indexes
- Currently indexing subject, participants, and thread message bodies or snippets if the body is not available
- Update initial sync to fetch 5000 message bodies per account
- Adds a new SearchMatcher
- Add new thread-search-index package to run in the worker window to
  init and keep thread search index up to date
- Converts Thread to ES6

TODO:
- Remove/Update suggestions dropdown
- Add tests

Test Plan: - TODO

Reviewers: evan, bengotow

Reviewed By: evan, bengotow

Differential Revision: https://phab.nylas.com/D2826
2016-04-04 17:15:19 -07:00
Ben Gotow 26fe05153c feat(offline-status): Show a bar when not connected to the API
Summary:
The TaskQueue does it's own throttling and has it's own processQueue retry timeout, no need for longPollConnected

Remove dead code (OfflineError)

Rename long connection state to status so we don't ask for `state.state`

Remove long poll actions related to online/offline in favor of exposing connection state through NylasSyncStatusStore

Consoliate notifications and account-error-heaer into a single package and organize files into sidebar vs. header.

Update the DeveloperBarStore to query the sync status store for long poll statuses

Test Plan: All existing tests pass

Reviewers: juan, evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D2835
2016-04-04 17:11:09 -07:00
Ben Gotow 04faa0769f log(sync-state): Send Account State Delta to mixpanel 2016-03-18 15:09:00 -07:00
Juan Tejada 812b64edec fix(snooze): Correctly query and create snooze categories per account
Summary:
- Was not properly updating the references to snoozed categories when
  accounts were added or removed
- Update whenCategoriesReady to make sure we listen until category syncing has concluded (Move inside CategoryStore)
- #1676, #1658

Test Plan: - TODO

Reviewers: evan, drew, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D2723
2016-03-14 15:36:39 -07:00
Ben Gotow c296e2e1d4 fix(sync): Do not paginate /metadata unless pluginsSupported 2016-03-10 16:03:36 -08:00