We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cfca37f commit 5e009d1Copy full SHA for 5e009d1
1 file changed
lib/client/doc.js
@@ -106,9 +106,13 @@ Doc.prototype.destroy = function(callback) {
106
doc.whenNothingPending(function() {
107
if (doc.wantSubscribe) {
108
doc.unsubscribe(function(err) {
109
- if (!err) doc.connection._destroyDoc(doc);
110
- if (callback) return callback(err);
111
- if (err) this.emit('error', err);
+ if (err) {
+ if (callback) callback(err);
+ else this.emit('error', err);
112
+ return;
113
+ }
114
+ doc.connection._destroyDoc(doc);
115
+ if (callback) callback();
116
});
117
} else {
118
doc.connection._destroyDoc(doc);
0 commit comments