diff --git a/lib/mongo_ascoltatore.js b/lib/mongo_ascoltatore.js index 2315dbc..0c8562f 100644 --- a/lib/mongo_ascoltatore.js +++ b/lib/mongo_ascoltatore.js @@ -226,15 +226,30 @@ MongoAscoltatore.prototype._handleCursorClosed = function (latest) { * @param latest * @private */ -MongoAscoltatore.prototype._checkCappedAndPoll = function(latest) { +MongoAscoltatore.prototype._checkCappedAndPoll = function(latest, retryCount) { debug('checkCappedAndPoll'); var that = this; this.collection.isCapped(function(err, isCapped) { - if (err) { - debug('checkCappedAndPoll -> Cannot stat isCapped. Give up'); - that.emit('error', new Error('Cannot stat if collection is capped or not')); - that._handlingCursorFailure = false; - return; + if (err) + { + if(!retryCount) + retryCount=0; + if(retryCount Cannot stat isCapped. Retry'); + retryCount++ + setTimeout(function(){ + that._checkCappedAndPoll(latest, retryCount); + },100*retryCount) + + return; + }else{ + debug('checkCappedAndPoll -> Cannot stat isCapped. Give up'); + + that.emit('error', new Error('Cannot stat if collection is capped or not')); + that._handlingCursorFailure = false; + return; + } } if (!isCapped) { debug('checkCappedAndPoll -> Collection is not capped. Give up');