You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
When issuing a "destroy" on HocuspocusProvider, the underlying websocket connection will be closed as well, however it will always try to reconnect again.
The faulty code seems to be the onClose event:
// The connection was closed by the server. Let’s just try again.
this.connect()
}
When I debugged the code, I noticed that event.reason == 'provider_initiated', so I think the code above there just needs a check for this type of close reason and set shouldConnect to false.
Steps to reproduce the bug
Steps to reproduce the behavior:
Create HocuspocusProvider
Call HocuspocusProvider.destroy
Expected behavior
Connection is properly closed and not reestablished.
The text was updated successfully, but these errors were encountered:
I noticed that I need to explicitly set preserveConnection option to false to cause the connection to be closed on destroy.
On that note though, I now instead want to try to preserve the connection and even though preserveConnection is set to true, the connection is closed for a moment each time a HocuspocusProvider is destroyed.
EDIT:
Tracing this a bit more it seems that when destroying a HocuspocusProvider a CloseMessage on the document which is fine.
However, it seems this causes the server to directly close the websocket connection, even though it still might be reused:
Have the same use case here: We are doing multiplexing with one HocuspocusProviderWebsocket and multiple HocuspocusProvider. However when we want to sync to a different document we destroy the HocuspocusProvider and create a new one. This works fine, but this triggers the Websocket to close ( like @olee traced already is done by the server handling the CLOSE message).
In our case we have open an overlay in our application which shows that the HocuspocusProviderWebsocket is not connected. When we change the document this overlay is triggered for 1 second which is annoying.
I think the correct place to fix this is in the CLOSE Message - the client needs to choose whether it wants the server to close the connection or not, depending on other HocuspocusProviders registered to that HocuspocusProviderWebsocket it should not close the connection per default. What do you think?
Description
When issuing a "destroy" on HocuspocusProvider, the underlying websocket connection will be closed as well, however it will always try to reconnect again.
The faulty code seems to be the onClose event:
hocuspocus/packages/provider/src/HocuspocusProviderWebsocket.ts
Lines 526 to 529 in fa2fb2e
When I debugged the code, I noticed that
event.reason == 'provider_initiated'
, so I think the code above there just needs a check for this type of close reason and setshouldConnect
to false.Steps to reproduce the bug
Steps to reproduce the behavior:
HocuspocusProvider.destroy
Expected behavior
Connection is properly closed and not reestablished.
The text was updated successfully, but these errors were encountered: