Comments (8)
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.
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.
(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.
I pushed a failing test case for this to the conflict-test branch (9857eeb)
from automerge-classic.
FWIW the failing test passes using the WASM backend.
from automerge-classic.
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.
How straightforward is it to migrate from the JS implementation to using the WASM backend?
from automerge-classic.
Thanks! I'll try it out at some point and see if any issues arise.
from automerge-classic.
Related Issues (20)
- Automerge Fails with "For 'properties/commit_title', nil is not a string." HOT 1
- Automerge.merge() is inconsistent HOT 5
- Maximum call stack exceeded when initializing Automerge.Text with large (500kb) string HOT 4
- Can't apply changes to clone HOT 1
- Uncaught TypeError: Unsupported type of value: function HOT 3
- Uncaught TypeError: Unsupported type of value: undefined HOT 6
- Keeping track of most recently used items HOT 3
- Γ "TypeError: Not a byte array: 133" error when userB receives data from userA. HOT 2
- indexOf fails in a proxy with undefined index HOT 1
- What are the strategies to sync with remote storage? HOT 6
- Can't install [email protected] because it has a dependency on [email protected] HOT 1
- save/load is not working for me (or maybe I'm doing something wrong) HOT 1
- Please create Go package HOT 1
- Text editor binding HOT 1
- No matching version found for [email protected] HOT 6
- Integration module federation with ReactJS HOT 6
- rollup can't find wasm exports HOT 1
- Cloudflare workers FinalizationRegistry not defined HOT 2
- get change message(s) from Automerge.getChanges() HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from automerge-classic.