Setting an upper limit on the size of a document

Hey, we’ve been using Yjs to build a collaborative songwriting app. On the whole the user experience is excellent, but we noticed things (predictably) degrade when editing very large documents. We’re setting an upper limit of document size client side to prevent this from happening; but it occurred to me that we cannot be sure a client hasn’t been compromised so wanted to also implement a hard limit server side to protect against malicious clients. Any pointers?

Yjs is a CRDT implementation and hence must retain metadata that increases the size of your document over time.

Many repetitive actions don’t add any metadata overhead (e.g. inserting content left-to-right in order, writing the same key in a Y.Map).

If you are using Y.Map, YKeyValue is a more efficient version that compresses much more efficiently. It is part of the y-utility package GitHub - yjs/y-utility: Utility features for Yjs

A hard limit is a good idea. Also, try to optimize the data representation so that the Yjs document doesn’t grow too much.