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

Don't close socket if preserveConnection is set in HocuspocusProvider #844

Open douira opened 1 month ago

douira commented 1 month ago

Sending the CloseMessage also has the effect of closing the socket according to its description.

I noticed that before patching this in the package, the socket would be closed when I called destroy on the provider even if it was supposed to preserve the connection. When using multiple providers on the same socket at once, it's important that no provider getting destroyed closes the whole socket. disconnecting the provider is not enough because it still has listeners on the document, socket, and elsewhere which is not acceptable.

douira commented 1 month ago

The test could be fixed by either