Skip to content
This repository has been archived by the owner on Mar 10, 2020. It is now read-only.

Commit

Permalink
Added retry mechanism for isCapped check
Browse files Browse the repository at this point in the history
  • Loading branch information
dushyantbangal authored Aug 18, 2017
1 parent bc72263 commit 59e59d5
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions lib/mongo_ascoltatore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<that._maxRetry)
{
debug('checkCappedAndPoll -> 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');
Expand Down

0 comments on commit 59e59d5

Please sign in to comment.