ARTICLE AD BOX
I am building a real time collaborative editor in JavaScript where multiple clients edit a shared JSON document. Updates are sent over WebSockets as JSON Patch style operations.
Constraints:
Clients apply optimistic local updates immediately Remote patches can arrive out of order Clients can go offline and later reconnect When reconnecting, the server replays missed operations The document can be deeply nested Users can undo and redo local changesThe problem is that concurrent edits to overlapping paths cause nondeterministic states across clients.
Example:
Client A applies: { op: "replace", path: "/user/name", value: "Alice" } Client B applies: { op: "replace", path: "/user", value: { name: "Bob", age: 30 } } Depending on patch order, different final states emerge.Right now I am:
Tracking a local operation queue
Storing version numbers per document
Rebasing remote patches on top of local unacknowledged patches
However this breaks down when patches mutate parent paths of already modified child paths.
I want to avoid pulling in a full CRDT framework unless absolutely necessary because of bundle size and complexity.
