Closed vineetdigit closed 1 year ago
Hi @vineetdigit,
This is the expected behavior. The "winner" is decided by the ydoc.clientID
of the document (which is a generated number). The higher clientID wins.
The reason is that this prevents a lot of other potential issues. E.g. assume that userA sets ymap.set('x', 0); ymap.set('y', 1000)
and userB sets ymap.set('x', 1000); ymap.set('y', 0)
. The result should be consistently either { x: 0, y: 1000 }
or { x: 1000, y: 0 }
- which result shouldn't matter.
Comparing by clientID (=integer) is also A LOT more efficient than comparing arbitrary values which requires a lot more checks.
For testing, you can set the clientID manually - so you can reproduce potential issues. Try setting yOurDoc.clientID = 0; yTheirDoc = 1; ..
Otherwise, please don't touch the clientID
;)
Also, thanks for your sponsorship! :heart: I would have sent you a thank-you mail, but couldn't find it in your account.
Describe the bug
I am recreating a document by merging updates from two documents which have common ancestor as shown below.
But the merged document randomly picks the value from either document.
I was hoping that the merged document consitently picks one value between iterations of the loop below.
To Reproduce
Output
Expected behavior
I am expecting the key to ALWAYS have the same value for all iterations of the loop
Environment Information
Huly®: YJS-340