Skip to content

Commit

Permalink
Merge 37d35f0 into a81e2c9
Browse files Browse the repository at this point in the history
  • Loading branch information
alecgibson committed Jul 22, 2020
2 parents a81e2c9 + 37d35f0 commit 25d3b19
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/client/presence/local-doc-presence.js
Expand Up @@ -23,6 +23,10 @@ LocalDocPresence.prototype = Object.create(LocalPresence.prototype);

LocalDocPresence.prototype.submit = function(value, callback) {
if (!this._doc.type) {
// If the Doc hasn't been created, we already assume all presence to
// be null. Let's early return, instead of error since this is a harmless
// no-op
if (value === null) return this._callbackOrEmit(null, callback);
var error = {
code: ERROR_CODE.ERR_DOC_DOES_NOT_EXIST,
message: 'Cannot submit presence. Document has not been created'
Expand Down
13 changes: 13 additions & 0 deletions test/client/presence/doc-presence.js
Expand Up @@ -945,4 +945,17 @@ describe('DocPresence', function() {
}
], done);
});

it('does not error when destroying presence for a deleted doc', function(done) {
var localPresence1 = presence1.create('presence-1');

async.series([
doc1.del.bind(doc1),
localPresence1.destroy.bind(localPresence1),
function(next) {
expect(Object.keys(presence1.localPresences)).to.be.empty;
next();
}
], done);
});
});

0 comments on commit 25d3b19

Please sign in to comment.