Warning about out of memory for y-webserver

I had a number of users all editing large documents (>50MB) when disaster struck. The standard y-webserver runs in nodejs and keeps open documents in memory to serve to clients when they connect. nodejs, however, comes with 512MB maximum heap size out of the box. In my case, it ran out of heap and crashed. This was particularly problematic because before or while it was crashing, y-webserver sent empty documents back to the connected clients, effectively deleting them.

The moral is that you should watch out that node is started with enough memory. This can be done with a larger setting than the 512 MB default for --max-old-space-size e.g.

/usr/bin/node --max-old-space-size=4096 /path_to/node_modules/.bin/y-websocket-server
2 Likes

Wow, that sounds like a devious bug! Thanks for pointing it out. How many documents did you have in memory at the time? 512 MBs still sounds relatively lot if it was just for syncing yDocs. Node.js doesn’t seem quite optimal for memory-optimized work but not much you can do about it for now.

That sending of empty docs seems quite bad and I wonder do you just have to make a if-case yourself or can the library handle it for you.