Skip to content

Commit

Permalink
Update to call _isInHArdRollback at the top of fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
dawidreedsy committed Mar 4, 2025
1 parent 6f3869c commit fd67b16
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/client/doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,8 @@ Doc.prototype._hardRollback = function(err) {
// Fetch the latest version from the server to get us back into a working state
var doc = this;
this._fetch({force: true}, function(fetchError) {
doc._isInHardRollback = false;

// We want to check that no errors are swallowed, so we check that:
// - there are callbacks to call, and
// - that every single pending op called a callback
Expand Down Expand Up @@ -1088,10 +1090,7 @@ Doc.prototype._hardRollback = function(err) {
inflightOp = null;
}

if (!pendingOps.length) {
doc._isInHardRollback = false;
return;
}
if (!pendingOps.length) return;
err = new ShareDBError(
ERROR_CODE.ERR_PENDING_OP_REMOVED_BY_OP_SUBMIT_REJECTED,
'Discarding pending op because of hard rollback during ERR_OP_SUBMIT_REJECTED'
Expand All @@ -1104,7 +1103,6 @@ Doc.prototype._hardRollback = function(err) {
allOpsHadCallbacks = util.callEach(pendingOps[i].callbacks, err) && allOpsHadCallbacks;
}
if (err && !allOpsHadCallbacks) doc.emit('error', err);
doc._isInHardRollback = false;
});
};

Expand Down

0 comments on commit fd67b16

Please sign in to comment.