Skip to content

Commit 0857be5

Browse files
committed
Update to call _isInHArdRollback at the top of fetch
1 parent 6f3869c commit 0857be5

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

lib/client/doc.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,8 @@ Doc.prototype._hardRollback = function(err) {
10581058
// Fetch the latest version from the server to get us back into a working state
10591059
var doc = this;
10601060
this._fetch({force: true}, function(fetchError) {
1061+
doc._isInHardRollback = false;
1062+
10611063
// We want to check that no errors are swallowed, so we check that:
10621064
// - there are callbacks to call, and
10631065
// - that every single pending op called a callback
@@ -1088,10 +1090,8 @@ Doc.prototype._hardRollback = function(err) {
10881090
inflightOp = null;
10891091
}
10901092

1091-
if (!pendingOps.length) {
1092-
doc._isInHardRollback = false;
1093-
return;
1094-
}
1093+
if (!pendingOps.length) return;
1094+
10951095
err = new ShareDBError(
10961096
ERROR_CODE.ERR_PENDING_OP_REMOVED_BY_OP_SUBMIT_REJECTED,
10971097
'Discarding pending op because of hard rollback during ERR_OP_SUBMIT_REJECTED'
@@ -1104,7 +1104,6 @@ Doc.prototype._hardRollback = function(err) {
11041104
allOpsHadCallbacks = util.callEach(pendingOps[i].callbacks, err) && allOpsHadCallbacks;
11051105
}
11061106
if (err && !allOpsHadCallbacks) doc.emit('error', err);
1107-
doc._isInHardRollback = false;
11081107
});
11091108
};
11101109

0 commit comments

Comments
 (0)