Git Product home page Git Product logo

Comments (8)

ept avatar ept commented on June 17, 2024 1

This is a bug; thank you for the nice test case. The conflict ought to show up regardless in which order the documents are merged. I found that to reproduce the bug, you don't even need nested objects β€”Β the following is sufficient to reproduce the issue:

const s1 = Automerge.change(Automerge.init('22'), doc => { doc.x = 1 })
const s2 = Automerge.change(Automerge.init('11'), doc => { doc.x = 2; doc.y = 3 })
const m1 = Automerge.merge(s1, s2)
console.log(Automerge.getConflicts(m1, 'x'))

Internal details follow. The problem occurs when the first argument to merge() has the greater actorId. In this case, mergeDocChangeOps first applies the change op (the assignment to x from the second argument to merge), then loads the next change op (the assignment to y from the second argument to merge) while docOp is still the assignment to x from the first argument to merge. At this point, keyMatches, listElemMatches, and foundListElem are all false, and so we don't take the branch at backend/new.js:1169, and in particular we never reach the call to updatePatchProperty at backend/new.js:1203. Hence, docOp is not added to the patch and so it doesn't show up in the conflict.

The bug only shows up if the second argument to merge contains another op which is loaded into changeOp; if there is no such op (e.g. if we remove the assignment to y in the example above), changeOp still contains the previous op, so keyMatches == true, and therefore the patch is updated as it should be.

I'm not sure right now how to best fix this bug. Given that we're moving towards making the Rust/Wasm implementation of Automerge the primary one, the most important thing is to ensure this bug doesn't occur there.

from automerge-classic.

pvh avatar pvh commented on June 17, 2024 1

It should be almost 100% compatible, aside from requiring waiting for the automerge-wasm blob to load (browsers block synchronous WASM loading). We're currently working through a last few things before an offical release (like improving docs) but you can try https://github.com/automerge/automerge-rs/tree/main/automerge-js in the meantime and pass along any feedback if you run into problems.

from automerge-classic.

pvh avatar pvh commented on June 17, 2024 1

(You should be able to yarn add automerge-wasm automerge-js. The latter will become automerge as part of the change-over process.)

from automerge-classic.

ept avatar ept commented on June 17, 2024

I pushed a failing test case for this to the conflict-test branch (9857eeb)

from automerge-classic.

alexjg avatar alexjg commented on June 17, 2024

FWIW the failing test passes using the WASM backend.

from automerge-classic.

ept avatar ept commented on June 17, 2024

Great, then I think we don't need to fix this bug in the JS implementation since it's going to be deprecated anyway.

from automerge-classic.

fo-fo avatar fo-fo commented on June 17, 2024

How straightforward is it to migrate from the JS implementation to using the WASM backend?

from automerge-classic.

fo-fo avatar fo-fo commented on June 17, 2024

Thanks! I'll try it out at some point and see if any issues arise.

from automerge-classic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.