-
Notifications
You must be signed in to change notification settings - Fork 140
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
Improve sync events #1290
Improve sync events #1290
Conversation
* Add "completed" status to `sync-done` (can finish with errored tasks) * Add number of remaining tasks in queue to `sync-req-done`
I added a fix for a subtle bug in the |
The changes look good, but when I run TSError: ⨯ Unable to compile TypeScript: 90 global["document"] = {} as Document; I don't get that error with the master branch; I'm not certain what's different. |
Thanks. I did not change anything in that file, so it's unlikely that this error is related to my changes. What's also weird is that GitHub didn't run the test actions for the last couple of commits. It still works fine for me on node 16 locally. |
@DougReeder Could you try removing your |
I deleted npm ERR! code ERESOLVE As noted, this PR doesn't change the dependencies, so I don't see how this issue could have been introduced by it. However. until I figure out what's going on, I can't sign off on this PR. :-( |
Ah. You need to use the https://remotestoragejs.readthedocs.io/en/latest/contributing/building.html#setup See also #1276 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for writing tests; that gives me a lot more confidence.
@@ -932,7 +932,7 @@ class Sync { | |||
log('[Sync] wireclient rejects its promise!', task.path, task.action, err); | |||
return this.handleResponse(task.path, task.action, { statusCode: 'offline' }); | |||
}) | |||
.then(completed => { | |||
.then(async (completed) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to have finishTask
be async and use await
throughout, but that can wait for a code cleanup.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, there are a lot of places where we will want to refactor using async/await, since it just wasn't available when the code was first written. In fact, we even had to use a library for promises at the time, because promises were the hot new thing while everyone was using callbacks still. ;)
sync-done
A sync can be done with uncompleted tasks from errored requests. It will then continue during the next periodic sync, trying to fetch the errored items again. However, for UI integration it is useful to know whether the full sync process is completed or not, so it doesn't have to show sync finishing and re-starting several times throughout a long process with many items, which may involve a few attempts here and there.
sync-req-done
This is just an indicator of overall status, since the internal queue only ever holds 100 items at most. However, for UI integration, it can be useful to know if there's a larger queue left. For example to show a dedicated sync status, as opposed to hiding it in order to not inform the user about small, relatively immediate sync procedures.