diff --git a/lib/client/doc.js b/lib/client/doc.js index 7bb47c33f..27bf0452a 100644 --- a/lib/client/doc.js +++ b/lib/client/doc.js @@ -311,7 +311,7 @@ Doc.prototype._handleSubscribe = function(error, snapshot) { this.inflightSubscribe = null; var callbacks = this.pendingFetch; this.pendingFetch = []; - if (request.callback) callbacks.push(request.callback); + if (request && request.callback) callbacks.push(request.callback); var callback; if (callbacks.length) { callback = function(error) { @@ -319,7 +319,7 @@ Doc.prototype._handleSubscribe = function(error, snapshot) { }; } if (error) return this._emitResponseError(error, callback); - this.subscribed = request.wantSubscribe; + this.subscribed = request && request.wantSubscribe; if (this.subscribed) this.ingestSnapshot(snapshot, callback); else if (callback) callback(); this._emitNothingPending();