Description
The problem I am facing
I'm trying to make my implementation of the HocuspocusProvider
more resilient to websocket issues (ex: downtime in hocuspocus server, auth issues, network connectivity) and am not sure how to handle failure states gracefully.
The solution I would like
It would be nice if I could catch all failure states related to the initialization of the connection - specifically the opening of the websocket and the authentication steps. If anything fails, I'd like to fallback to a default value for prosemirror (or a default Y Doc, more generically) so that the user could at least edit content instead of looking at a blank textfield. Additionally, when a failure state is captured that indicates that reconnection is unlikely, it'd be nice to tell the provider to stop trying to reconnect.
I don't really need to handle cases where the connection drops while editing, since the user already has text they're working with. This is more about the initialization of the Y doc.
Alternatives I have considered
Feel like I've tried just about everything to detect the initial websocket connection failing due to connectivity issues, and nothing is working. Specifically provider.connect().catch()
is not called, and you can't try/catch websocket connection failures. onAuthenticationFailed
seems doable but if I implement that I still don't know how to tell the provider to stop trying to reconnect.
Additional context
I'm using y-prosemirror.