-
-
Notifications
You must be signed in to change notification settings - Fork 134
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
Hocuspocus >=2.7.0 does not work with React in strict mode / Lexical #760
Comments
I encountered a similar challenge while integrating the lexical editor with a collaboration plugin using the hocus pocus provider. While the collaboration worked seamlessly between two tabs in the browser, attempting the same on a regular tab and in incognito mode resulted in unsynchronized changes. I also tried connecting two different computers to the same network with the help of mobile network and then tried using the editor with collab but the changes did not sync. Once I remove the strict mode on my react app everything worked as expected. |
@GermanJablo I just see that you have |
No, that's not the problem, it still doesn't work removing that line :) |
hmmm, not sure what's the issue here to be honest. The providers don't even emit the synced event. I think the issue is that both providers bind to the socket, the 1st gets destroyed, then unbinds from the socket, and then also unbinds the 2nd (because they are using the same document name). We changed something there with 2.7.0 to make it (a lot) more performant. Not sure what's the fix here, apart from making sure that the provider gets created just once. |
I started having similar problems when I call provider.disconnect() and then after some time provider.connect(). This is similar to what can happen in React's strict mode. (I also pass preserveConnection: false to the constructor) But I have this problem since version 2.6.0, maybe you can check this version for yourself too? I have a suspicion about this PR, but these are just my guesses |
I've also stumbled upon this issue with |
Description
As of version 2.7.0 hocuspocus does not synchronize if react is in strict mode.
Steps to reproduce the bug
npm run dev
and in other consolenpm run collab-server
reactStrictMode
property ofnextjs.config.ts
to false and it will work, or alternatively downgrade hocuspocus to version2.6.1
.Environment?
The text was updated successfully, but these errors were encountered: