New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sync with live: true triggers "change" events twice #4293
Comments
Certainly not by design, just a straight up bug I think |
I poked around a bit: I'm unfamiliar with how everything fits together but I can say with confidence that your journey to fix this may start with this line: https://github.com/pouchdb/pouchdb/blob/master/lib/sync.js#L80 if (opts.live) {
this.push.on('complete', self.pull.cancel.bind(self.pull));
this.pull.on('complete', self.push.cancel.bind(self.push));
} Not a great lot of help, but a start :) |
Mmm yeah if this only occurs with |
Added a test here, its a bug in |
Fairly trivial fix - 764ba8a, however looks like the retry tests are broken somehow (they depend on extra events being fired) and now failing |
So the retry test depends on this behaviour, the retry test does rep.on('change', postNewDoc) to post docs in a loop, currently we only fire the change event once the checkpoint has successfully written, if that fails, the batch fails, replication gets retried but the next document is already written so it will fire the empty change event |
We can change the behaviour for replication to fire change events before the checkpointer, however that is going to have a knock on effect (the tests fail when I do that) |
Fixed in fe4cc24 |
Output looks like this
WIthout the
live: true
option, it correctly triggers the "change" events only once per document. Is this by design? Or some kind of race condition maybe?The text was updated successfully, but these errors were encountered: