Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix ack
  • Loading branch information
alecgibson committed Jan 28, 2025
commit 3119864fb6a66398e3446f811eb501e952f64c8a
8 changes: 4 additions & 4 deletions lib/client/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,11 @@ Doc.prototype._handleOp = function(err, message) {
return this.emit('error', err);
}

var shouldAck = !!this._transaction || (
this.inflightOp &&
var isInflightAck = this.inflightOp &&
message.src === this.inflightOp.src &&
message.seq === this.inflightOp.seq
);
message.seq === this.inflightOp.seq;
var isTransactionAck = !!this._transaction && message.src === this.connection.id;
var shouldAck = isInflightAck || isTransactionAck;
if (shouldAck) {
// The op has already been applied locally. Just update the version
// and pending state appropriately
Expand Down
10 changes: 4 additions & 6 deletions test/client/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,12 @@ module.exports = function() {
doc.create.bind(doc, {tricks: ['fetch']}),
remoteDoc.fetch.bind(remoteDoc),
remoteDoc.submitOp.bind(remoteDoc, [{p: ['tricks', 0], ld: 'fetch'}]),
doc.submitOp.bind(doc, [{p: ['tricks', 1], li: 'sit'}], {transaction: transaction}),
doc.submitOp.bind(doc, [{p: ['tricks', 2], li: 'shake'}], {transaction: transaction}),
remoteDoc.fetch.bind(remoteDoc),
function(next) {
expect(remoteDoc.data).to.eql({tricks: []});
next();
doc.submitOp([{p: ['tricks', 1], li: 'sit'}], {transaction: transaction}, errorHandler(next));
doc.submitOp([{p: ['tricks', 2], li: 'shake'}], {transaction: transaction}, errorHandler(next));
transaction.commit(next);
},
transaction.commit.bind(transaction),
doc.fetch.bind(doc),
remoteDoc.fetch.bind(remoteDoc),
function(next) {
expect(remoteDoc.data).to.eql({tricks: ['sit', 'shake']});
Expand Down