Skip to content
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

For some reason the YDoc sometimes remains unsynchronized when loading the page #6

Closed
linspw opened this issue May 4, 2023 · 2 comments

Comments

@linspw
Copy link

linspw commented May 4, 2023

Gravacao.de.tela.de.04-05-2023.20.14.14.webm

This happens on half the tries. It does not generate errors in the console.
Maybe it could be a concurrency issue. I've looked at the snapshot data and it's correct.

My Workaround is force sync again (works with it) 🤔

    const ydoc = new Y.Doc()
    this.provider = new HocuspocusProvider({
      url: `ws://localhost:8000/workspace/v1/documents/${this.document.id}`,
      name: String(this.document.id),
      document: ydoc,
      onSynced(data) {
        console.log(data)
      },
    })
    this.provider.on('connect', () => {
      this.provider?.forceSync()
    })

    this.editor = new Editor({
      extensions: [
        StarterKit.configure({
          history: false,
        }),
        Collaboration.configure({
          document: ydoc,
          field: 'content',
        }),
        CollaborationCursor.configure({
          provider: this.provider,
          user: { name: this.getRandomName(), color: this.getRandomColor() },
        }),
      ],
    }

Thanks in advance for your attention, Stefan!

Your project is amazing!

@stefanw
Copy link
Owner

stefanw commented May 6, 2023

I looked into this and I'm currently suspecting that HocuspocusProvider cannot read multiple y-protocol messages in one message receive (it could and probably should though). I'm looking into a workaround, but it is a bit annoying as I apparently need to split one initial reply (ie sync step 2, sync step 1 and awareness update) into multiple sends which could be one send.

@stefanw
Copy link
Owner

stefanw commented May 15, 2023

I added a setting to disable message pipelining. And I also found and fixed some bug in regards to syncing.

One other pesky synchronization bug that would lose messages was because of a broken/outdated version of the Python redis package (see this issue). Upgrading to redis>=4.5.5 (released 8.5.2023) fixes this.

Latest version v0.0.5 fixes these issues.

Docker compose example project includes now a TipTap editor and the docs have a more detailed guide for Tiptap.

@stefanw stefanw closed this as completed May 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants