text icon indicating copy to clipboard operation
text copied to clipboard

Reconnect handling

Open juliusknorr opened this issue 2 years ago • 3 comments

I noticed when testing #4938 that there seems to be a case when a connection is offline long enough that the reconnect is not working as expected.

When trying to address the issue there by dropping the disconnected websocket provider with the following patch I noticed that after reconnecting the offline client would no longer send changes while still picking up the ones from the other clients.

diff --git a/src/components/Editor.vue b/src/components/Editor.vue
index 407004d99..879928d03 100644
--- a/src/components/Editor.vue
+++ b/src/components/Editor.vue
@@ -423,6 +423,7 @@ export default {
                reconnect() {
                        this.contentLoaded = false
                        this.hasConnectionIssue = false
+                       this.$providers.forEach(p => p.destroy())
                        this.close().then(this.initSession)
                        this.idle = false
                },

juliusknorr avatar Oct 31 '23 14:10 juliusknorr

Actually seems like after the reconnect the step is not pushed at all so we have a diverging state between both clients

Failing step: Screenshot 2023-10-31 at 15 23 16

First successful push after reconnect: Screenshot 2023-10-31 at 15 23 46

juliusknorr avatar Oct 31 '23 14:10 juliusknorr

https://github.com/nextcloud/text/pull/5082 was an attempt but unclear how it could have an effect, needs further debugging.

  • [ ] Clarify state behaviour of Editor.vue and related components (sync service, connection, websocket polyfill) in the lifecycle of editing especially with reconnect, what objects are reused, recreated, are there any leftovers still active?
  • [ ] @max-nextcloud Looking into preserving the queue from one websocket polyfill instance to another
  • [ ] Try commenting out the code part that makes the editor read only for easier debugging
  • [ ] See if applying the document state again after reconnect causes troubles (maybe rather just sync the steps instead?)

juliusknorr avatar Dec 06 '23 14:12 juliusknorr

Idea:

  • for easier debugging try to add buttons locally to disconnect or reconnect in editor.vue

juliusknorr avatar Dec 06 '23 17:12 juliusknorr