As for the determination condition of resync in y-websocket library

Is it more appropriate to execute resync when the WS instance object exists and the connection state is OPEN?

For example:

if (this.ws && this.ws.readyState === WebSocket.OPEN)

Yes, that would be more accurate. it probably doesn’t make a difference in practice. However, would be happy to accept a PR!