Skip to content

Type, document, and refactor Sync, port tests to Mocha #1331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 47 commits into
base: master
Choose a base branch
from

Conversation

raucao
Copy link
Member

@raucao raucao commented Jun 8, 2025

Includes some small other improvements. However, this PR is mostly about properly typing and documenting sync, as well as making the functions more readable by using async/await in many places.

Noteworthy additional changes:

  • Adds a new event called "sync-started", when a periodic/background sync has started (but not when outgoing changes are synced immediately).
  • Emit conflict change events asynchronously, so app developers don't have to handle them in a special way, improve conflict event docs
  • Do not emit conflict events for nodes that were deleted both locally and remotely (d04f334)
  • Fix remote deletes not handled properly when folder has local changes (098962d)
  • For more, see referenced issues below

refs #1251 (where I added sub-issues that are all easier to tackle with these changes)
refs #1270
closes #1173
closes #839
fixes #1335
fixes #1204

P.S.: I rebased the branch as much as possible before opening the PR. But there are too many conflicts when trying to consolidate the rest even more.

raucao added 5 commits June 9, 2025 13:29
Use _rs_init instead of custom prototype properties
Only log the message as debug log, without the stack trace

refs #839
In order for devs not having to wait feature loading before managing
access and caching settings, we need those classes to be instantiated
onthe prototype already
@raucao
Copy link
Member Author

raucao commented Jun 9, 2025

FYI, I opened #1334 against this one, because it requires the new cachinglayer test suite. Can re-open against master later, if it doesn't get merged here.

@raucao
Copy link
Member Author

raucao commented Jun 16, 2025

Added a rather useful change for conflict events: handling them in apps doesn't require manually using setTimeout or similar anymore.

Also, My Favorite Drinks now has support for updating drinks and it will automatically handle conflicts:

https://github.com/remotestorage/myfavoritedrinks/blob/master/app.js#L50-L59

https://myfavoritedrinks.remotestorage.io

@raucao raucao force-pushed the feature/1251-sync branch from 012e75d to 91bf93d Compare June 16, 2025 09:36
This way, apps can use these the same way as they can use other change
events.
raucao added 3 commits June 18, 2025 12:29
This can cause documents to either not be deleted at all when they
should be, but at the least for the parent folder's `local` itemsMap to
become inconsistent and potentially persist forever, because it can
never be the same as the remote itemsMap again (which is the criterium
for removing it).
No changes can be lost when documents are deleted on both ends
@raucao raucao force-pushed the feature/1251-sync branch from 11ad749 to d04f334 Compare June 18, 2025 10:43
@raucao
Copy link
Member Author

raucao commented Jun 18, 2025

I was able to address almost all of the sub-issues of #1251 in this PR now. The couple of issues that are left open should be addressed in separate PRs after this one is merged.

It doesn't matter if a client received `sync-started` or not. When there
are no more tasks to run after any task has finished successfully, the
sync is done.

Also removes a superfluous second log statement for when sync is done.
@DougReeder
Copy link
Contributor

The tests pass on my dev machine, the tests appear to cover new/changed functionality, and there's no code smell. But I'm not familiar enough with the syncing code sign off on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants