I built Synapse to see if I could make two people edit the same paragraph offline, reconnect, and lose nothing. This is what I learned about CRDTs along the way, including two things I got wrong.
Why not OT
Operational transformation needs a server to put every edit in order and rewrite late ones. That works, but it means a client that was offline for 20 minutes comes back with a pile of old edits the server has to rebase. I did not want my design to depend on that, so I used Yjs, which is a CRDT. Every character has an identity, so copies can merge in any order and end up the same.
The first thing I got wrong
I wrote a small script where two people type at the same spot while offline, then I sent their edits to two observers in opposite orders. I expected the arrival order to decide the result. It did not. Both observers ended with the same text. Yjs breaks the tie using each copy's client ID, and every copy compares the same IDs.…