Hi guys, quick question about y-websocket server:
I have a y-websocket server in a docker container on a minikube pod (so single pod, single node), with no persistence specificed. I have a tiptap editor in a sibling container that uses this server to broadcast updates. Somehow, when I restart this pod, the rooms that I created for docs preserve their content. How is this possible? Even when there are no other peers connected, this seems to work.
I believe by default, websocket server uses a levelDB database persisted to the local file system. See utils.js in y-websocket/bin
The websocket server acts as one in-memory peer. As long as one client stay alive, the documents will get re-shared between peers.
Hey @braden correct me if I’m wrong, but it seems like if the YPERSISTENCE env variable isn’t set, it doesn’t persist to levelDB (utils.js line 29).
@luishdz1010 so if I understand you correctly, as long as one client (for example, one browser tab running my app) is active when I restart the kubernetes pod containing my y-websocket server, all documents will survive & be re-shared? Even the ones I wasn’t connected to? Because I believe that behavior is what I’ve been experiencing.
@tambo Correct on both accounts :). If a Doc is alive in memory anywhere, it will replicate as soon as it reconnects.
For local development I close all my browser tabs THEN kill the server THEN clear the leveldb… otherwise the data keeps coming back to life…