hocuspocus icon indicating copy to clipboard operation
hocuspocus copied to clipboard

HocusPocusProvider V2 initiates 2 connections despite setting the connect flag to false

Open ghost opened this issue 2 years ago • 4 comments

Description The HocusPocusProvider initiates 2 connections to our YJS backend despite setting the connect flag (from v1) to true. It should set up 1 connection.

Steps to reproduce the bug Steps to reproduce the behavior:

  1. Go to the examples in the repository https://github.com/BitPhinix/slate-yjs .
  2. Upgrade the hocuspocus version on both the client and the server.
  3. Open the client in a browser. And open the Network tab.
  4. You would see 2 connections established to the hocuspocus backend.

Expected behavior A single connection should be formed between the client and the server.

Screenshot, video, or GIF Screenshot 2023-04-29 at 11 56 52 PM

Environment?

  • operating system: MacBook Pro 2021 16 inch Apple M1 Max Ventura 13.3.1
  • browser: Brave
  • mobile/desktop: Desktop
  • Hocuspocus version: 2.0.6

Additional context The problem seems to be in this line where the connect parameter is not passed to the configuration.: https://github.com/ueberdosis/hocuspocus/blob/ed6441c1d82e614aea388dfb84617c691d18d524/packages/provider/src/HocuspocusProvider.ts#L220

ghost avatar Apr 29 '23 21:04 ghost

@osamatanveer I've just added an example to the provider documentation. If you want to use multiplexing, you'll have to create the websocket separately from the provider (see https://tiptap.dev/hocuspocus/provider/examples#multiplexing).

janthurau avatar May 14 '23 20:05 janthurau

Thanks @janthurau. We're not trying to use multiplexing. It is just that when we connect using editor.connect() we see 2 web socket connection opened in the network tab. We still are facing this issue.

ghost avatar Jun 27 '23 19:06 ghost

The same issue for me, as a dirty workaround I disconnect the configured websocket provider in addition to the Hocuspocus provider:

        provider.configuration.websocketProvider.disconnect()
        provider.disconnect()

Looks dirty, but works fine to me.

aonnikov avatar Sep 29 '23 09:09 aonnikov

The same issue for me, as a dirty workaround I disconnect the configured websocket provider in addition to the Hocuspocus provider:

        provider.configuration.websocketProvider.disconnect()
        provider.disconnect()

Looks dirty, but works fine to me.

It looks like works fine to me too , thx

wangfupeng1988 avatar Jul 15 '24 08:07 wangfupeng1988