-
Notifications
You must be signed in to change notification settings - Fork 108
fix(sync): send first update without initial document state #7787
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
Conversation
Process initial document state as incoming message. This way it will be tracked as received from the remote server by y-websocket and the update send to the server will exclude it. Also use the sync services `opened` event inside WebsocketPolyfill rather than mixing async `syncService.open().then` and event handling. This allows us to emit `opened` and then `sync` from `syncService.open()`. Signed-off-by: Max <max@nextcloud.com>
|
/backport to stable32 |
|
/backport to stable31 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7787 +/- ##
==========================================
- Coverage 60.19% 60.17% -0.02%
==========================================
Files 502 502
Lines 38561 38572 +11
Branches 1135 1134 -1
==========================================
+ Hits 23210 23212 +2
- Misses 15245 15254 +9
Partials 106 106 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Cypress failures are due to nextcloud/server#55726 |
| return [ | ||
| 'steps' => $stepsToReturn, | ||
| 'version' => $newVersion, | ||
| 'version' => isset($documentState) ? $document->getLastSavedVersion() : 0, |
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.
Can you tell if this has any other side effects? We now no longer return the latest version (number of steps in the db) but just the last saved. We used this in the past to compare and see if the document had unsaved changes, but I think that part was changed already.
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.
Otherwise $newVersion is no longer used as a variable
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.
Good catch wrt $newVersion. We were not using the version in the response on the client side anymore.
The unsaved changes check is on the server when cleaning up docs, right? That should still work. this is not changing the data structures there.
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.
Right there we still have it, i just remembered that we also used it in the frontend in the early days
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.
General approach makes sense but only looked at the code, not tested
6bc7587 to
8763eb9
Compare
* Emit the documents last saved version in the push response if document state is send as well. * Otherwise send the version as 0 so it cannot increase the sync service version. * Use the versions returned by create and push requests alongside the document state to construct a consistent step with the last saved version that matches the document state. This will result in the sync service version getting bumped to the documents last saved version once the coresponding document state has been processed. Signed-off-by: Max <max@nextcloud.com>
Signed-off-by: Max <max@nextcloud.com>
8763eb9 to
205c7cb
Compare
This comment was marked as resolved.
This comment was marked as resolved.
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 went through the code changes once again, stepped through processing steps in the frontend with debugger (to make sure the $version = 0 doesn't have an impact there) and tested with three clients in different browsers. Didn't catch anything.
Process initial document state as incoming message.
This way it will be tracked as received from the remote server by y-websocket
and the update send to the server will exclude it.
Also use the sync services
openedevent inside WebsocketPolyfillrather than mixing async
syncService.open().thenand event handling.This allows us to emit
openedand thensyncfromsyncService.open().