automerge / hypermerge

Build p2p collaborative applications without any server infrastructure in Node.js
MIT License
1.28k stars 66 forks source link

Inconsistent reuse of sequence number 1 #11

Closed Firescar96 closed 4 years ago

Firescar96 commented 6 years ago

I made an adaptation of the chat example to use a path on the local filesystem instead of memory. I tried both sending a string as a path, and using the random-access-file library in place of random-access-memory but got the same error. Snippets of the example with changed sections are below

************
class Channel extends EventEmitter {
  constructor ({channelKey, nick, path}) {
    super()
    this.channelKey = channelKey
    this.nick = nick
    this.hm = new Hypermerge({path: path})
    this.hm.once('ready', this.setup.bind(this))
  }
************
  /**
   * Getter to return the number of connections for the UI
   */
  getNumConnections () {
    return this.hm.swarm.connections.length
  }
}

//change this to channelKey after on second run
let KEY =null;
let chan1 = new Channel({nick: 'a1', path: 'a1/', channelKey: KEY})
chan1.on('ready', () => {
  console.log('key', chan1.channelKey);
  console.log('doc in chan1', chan1.doc);
  let chan2 = new Channel({nick: 'a2', channelKey: chan1.channelKey, path:'a2')})
  chan2.on('ready', (chan3) => {
    let docId = chan2.hm.getId(chan2.doc);
    let newdoc = chan2.addMessageToDoc('hello world');
    console.log('final', docId, newdoc);
  })
})

To reproduce error run the code once. Then change KEY to be the displayed value and run the code again.

Firescar96 commented 6 years ago

I found a solution, bumping the version of automerge from 0.7 to 0.8

EDIT: this solution only worked temporarily, the issue persists

pvh commented 4 years ago

Hello - I'm closing this out because I think it should be fixed, and if it isn't, the current hypermerge implementation is pretty much a rewrite so it would probably be a new and unrelated bug.