sharedb 5.2.0 → 5.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -30,10 +30,20 @@ LocalDocPresence.prototype.submit = function(value, callback) {
|
|
|
30
30
|
// be null. Let's early return, instead of error since this is a harmless
|
|
31
31
|
// no-op
|
|
32
32
|
if (value === null) return this._callbackOrEmit(null, callback);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
|
|
34
|
+
var error = null;
|
|
35
|
+
if (this._doc._isInHardRollback) {
|
|
36
|
+
error = {
|
|
37
|
+
code: ERROR_CODE.ERR_DOC_IN_HARD_ROLLBACK,
|
|
38
|
+
message: 'Cannot submit presence. Document is processing hard rollback'
|
|
39
|
+
};
|
|
40
|
+
} else {
|
|
41
|
+
error = {
|
|
42
|
+
code: ERROR_CODE.ERR_DOC_DOES_NOT_EXIST,
|
|
43
|
+
message: 'Cannot submit presence. Document has not been created'
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
37
47
|
return this._callbackOrEmit(error, callback);
|
|
38
48
|
};
|
|
39
49
|
|
package/lib/util.js
CHANGED
|
@@ -9,7 +9,9 @@ exports.hasKeys = function(object) {
|
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
var hasOwn;
|
|
12
|
-
exports.hasOwn = hasOwn = Object.hasOwn ||
|
|
12
|
+
exports.hasOwn = hasOwn = Object.hasOwn || function(obj, prop) {
|
|
13
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
14
|
+
};
|
|
13
15
|
|
|
14
16
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger#Polyfill
|
|
15
17
|
exports.isInteger = Number.isInteger || function(value) {
|
package/package.json
CHANGED
|
@@ -829,6 +829,20 @@ describe('DocPresence', function() {
|
|
|
829
829
|
], done);
|
|
830
830
|
});
|
|
831
831
|
|
|
832
|
+
|
|
833
|
+
it('errors local presence when doc is in hard rollback', function(done) {
|
|
834
|
+
var localPresence1 = presence1.create('presence-1');
|
|
835
|
+
|
|
836
|
+
doc1.on('error', function(error) {
|
|
837
|
+
expect(error).to.be.equal('some error');
|
|
838
|
+
});
|
|
839
|
+
doc1._hardRollback('some error');
|
|
840
|
+
localPresence1.submit({index: 1}, function(error) {
|
|
841
|
+
expect(error.code).to.be.equal('ERR_DOC_IN_HARD_ROLLBACK');
|
|
842
|
+
done();
|
|
843
|
+
});
|
|
844
|
+
});
|
|
845
|
+
|
|
832
846
|
it('returns errors sent from the middleware', function(done) {
|
|
833
847
|
backend.use(backend.MIDDLEWARE_ACTIONS.sendPresence, function(request, callback) {
|
|
834
848
|
callback('some error');
|