automerge / automerge-classic

A JSON-like data structure (a CRDT) that can be modified concurrently by different users, and merged again automatically.
http://automerge.org/
MIT License
14.75k stars 467 forks source link

`automerge.generateSyncMessage` --> the generate message has no changes there, automerge v.2.2.4 #536

Closed mcchran closed 3 months ago

mcchran commented 3 months ago

Hello team!

First things first, kudos for the project!

I am using automerge v2.2.4 to sync docs across multiple clients. I am not using the automerge-repo FYI. So I came across the following problem while generating a SyncMessage to share over the network:

In the example bellow dummyChanges is a list of all changes perform to the document. However these changes are not included in the msg generated by the automerge.generateSyncMessage function. msg is not nil it just does not include any changes.

        const dummyDoc = automerge.change(automerge.from(
            {content: ""}), doc => { doc.content = "dummy" })
        console.log("document to be sent is: ", dummyDoc)
        const dummyChanges = automerge.getAllChanges(dummyDoc)
        console.log(dummyChanges)
        let dummyState = automerge.initSyncState()
        let msg: Uint8Array | null = null;
        [dummyState, msg] = automerge.generateSyncMessage(dummyDoc, dummyState)

        if (msg) {
            console.log("the decoded message is: ")
            console.log(automerge.decodeSyncMessage(msg))
        }

Any idea ?

I am not sure if I miss anything here, there is plenty of documentation out there (some of it outdated) so I am little bit confused regarding iff this is an issue ...

Cheer, C.

mcchran commented 3 months ago

closing the issue, accidentally opened in the wrong Repo!