automerge / mpl

a p2p document synchronization system for automerge
MIT License
280 stars 20 forks source link

peer clocks don't reset when we change docIds #10

Open choxi opened 7 years ago

choxi commented 7 years ago

If Alice and Bob both open up the same document, and then Alice creates a new document, Alice keeps Bob's vector clock in deltaRouter.clocks even though its for the wrong docId now. You can see this by reproducing these steps and inspecting app.store.deltaRouter.clocks in the Alice's web inspector before and after we change documents -- we should theoretically not have any vector clocks stored because Bob has never opened the document that Alice is on but instead we do still have his vector clock.

I'm not sure how this would manifest as a bug in Trellis, but it could be causing problems especially in conjunction with https://github.com/inkandswitch/ampl/issues/9.

pvh commented 7 years ago

That's definitely wrong, but it works sometimes because when the other client changes docId they should send a new empty vector clock. Still, in many cases, it will get clockMax()'d against the other one and lead to problems. I think it probably works okay on a fork

When we change docId we should clear clocks[].