Desktop, Mobile: Automatically retrigger the sync if there are more unsynced outgoing changes when sync completes#12989
Merged
laurent22 merged 20 commits intolaurent22:devfrom Sep 13, 2025
Conversation
…mrjo118/joplin into additional-sync-after-completed
laurent22
reviewed
Sep 8, 2025
| // 3. DELTA: Find on the sync target the items that have been modified or deleted and apply the changes locally. | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied | ||
| public async start(options: any = null) { | ||
| public async start(options: any = null): Promise<any> { |
Owner
There was a problem hiding this comment.
We don't set the return value normally, it should be implied
Contributor
Author
There was a problem hiding this comment.
That is needed to get around a compile error, due to the function now invoking itself and returning the value
Owner
There was a problem hiding this comment.
Oh that's right, it's needed in this case. Thanks for clarifying
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On mobile, sync is triggered continuously as the user types. This helps to ensure that the latest changes get uploaded to the server, particularly because the Joplin mobile app does not support syncing in the background. Due to the synchronization process having multiple stages, it is possible that the continuous sync can stop prior to the latest change being uploaded, leaving unsynced the last characters the user enters when finishing editing a note. This is because the upload step of the sync suppresses multiple changes to the same file within the loop (to avoid a potential infinite loop) and also, if changes are saved during the delta step of the sync process (which runs last), the loop for the changes to upload would have ended at this point. This can result in conflicts, if the user closes or minimises the app after this happens (which is likely, because the sidebar would show that the sync is completed), and then starts using Joplin on another device.
In order to remedy this, I have addressed this in 2 ways:
Testing
Please note, the behaviour changes would be very hard to test with automated tests, due to the sync context object being reset before being returned by the start() function, and also because some of the error handling is disabled when running in an automated test (see usage of shim.isTestingEnv()). I have therefore done extensive manual testing.
After applying this code change, when the plugin's sync indicator is stuck on the editing icon, exiting the note editor and manually triggering the sync shows fetches only, and no updates being made. Also, in the log it contains 'Processing a path that has already been done: %s. The user is making changes while the sync is in progress' entries during the period the changes were made
Video of the behaviour in the current app:
Original.app.mp4
Video of the behaviour with the code changes (this was recorded before the logging was added, so the logging results shown are not up to date):
New.change.mp4