ueberdosis / hocuspocus

The CRDT Yjs WebSocket backend for conflict-free real-time collaboration in your app.
https://tiptap.dev/docs/hocuspocus/introduction
MIT License
1.19k stars 115 forks source link

Yjs was already imported. This breaks constructor checks and will lead to issues! #753

Closed kongweiying2 closed 8 months ago

kongweiying2 commented 8 months ago

Description There is a critical error that displays in the console. This is related to yjs and there is an entire thread dedicated to it, but despite trying various fixes, none of these have resolved the issue.

"Yjs was already imported. This breaks constructor checks and will lead to issues!"

https://github.com/yjs/yjs/issues/438

Steps to reproduce the bug Steps to reproduce the behaviour:

  1. Go to the deployment here:

https://lifemap-git-calculator-eusaybia.vercel.app/q/000000

Refer to the repo here:

This is where TipTapCollabProvider is initialised: https://vscode.dev/github.com/Eusaybia/lifemap/blob/calculator/src/backend/QiStore.tsx#L65-L66

This is where Y.js is imported: https://vscode.dev/github/Eusaybia/lifemap/blob/calculator/src/core/Model.tsx

  1. Open the console.
  2. Filter by critical errors
  3. Observe the message

Expected behavior This message shouldn't appear, and Yjs shouldn't be reimported either.

Screenshot, video, or GIF N/A Environment? Irrelevant, it will definitely appear on your machine.

Additional context Solutions I've already tried:

  1. I've tried updating to the latest version of Hocuspocus packages. No difference. #358
  2. I've tried making the files which contain the editor or references to TipTapCollabProvider client side rendered, since I'm using Next.js https://github.com/yjs/yjs/issues/438
svenadlung commented 8 months ago

Hm, can't open your files. Can you show your included packages and version numbers/package-lock.json?

kongweiying2 commented 8 months ago

package.json yarn.json

What do you see when you try and open the vscode link? I've shared it before and other people can access it.

svenadlung commented 8 months ago

There was a bug in @tiptap-pro/extension-collaboration-history lately. Can you please try updating the package to > v2.4.1.

The VS Code fails with this message: Screenshot 2023-12-02 at 18 12 09@2x

English translation: The current workspace is not a valid repository. Would you like to open another repository?

kongweiying2 commented 8 months ago

@svenadlung Upgrading fixed the problem, thanks. Also, a related question, do extensions like the collaboration-history have certain dependencies on which version of tiptap/core they work with?

svenadlung commented 7 months ago

@kongweiying2, if this is the case, it should be regulated via the peer deps. I am not aware of this in this specific case.