lib/mongodb/mongodb-core/lib/connection/pool.js
function _connectionFailureHandler(self) {
      return function() {
        if (this._connectionFailHandled) return;
        this._connectionFailHandled = true;
        // Destroy the connection
        this.destroy();
        // Count down the number of reconnects
        self.retriesLeft = self.retriesLeft - 1;
        // How many retries are left
        if (self.retriesLeft <= 0) {
          // Destroy the instance
          self.destroy();
          // Emit close event
          self.emit(
            'reconnectFailed',
            new MongoNetworkError(
              f(
                'failed to reconnect after %s attempts with interval %s ms',
                self.options.reconnectTries,
                self.options.reconnectInterval
              )
            )
          );
        } else {
          self.reconnectId = setTimeout(attemptReconnect(self), self.options.reconnectInterval);
        }
      };
    }
function _connectionFailureHandler(self) {
      return function() {
        if (this._connectionFailHandled) return;
        this._connectionFailHandled = true;
        // Destroy the connection
        this.destroy();
        // Count down the number of reconnects
        self.retriesLeft = self.retriesLeft - 1;
        // How many retries are left
        if (self.retriesLeft <= 0) {
          // Destroy the instance
          self.destroy();
          // Emit close event
          self.emit(
            'reconnectFailed',
            new MongoNetworkError(
              f(
                'failed to reconnect after %s attempts with interval %s ms',
                self.options.reconnectTries,
                self.options.reconnectInterval
              )
            )
          );
        } else {
          self.reconnectId = setTimeout(attemptReconnect(self), self.options.reconnectInterval);
        }
      };
    }
function _connectionFailureHandler ( self ) { return function ( ) { if ( this . _connectionFailHandled ) return ; this . _connectionFailHandled = true ; // Destroy the connection this . destroy ( ) ; // Count down the number of reconnects self . retriesLeft = self . retriesLeft - 1 ; // How many retries are left if ( self . retriesLeft <= 0 ) { // Destroy the instance self . destroy ( ) ; // Emit close event self . emit ( 'reconnectFailed' , new MongoNetworkError ( f ( 'failed to reconnect after %s attempts with interval %s ms' , self . options . reconnectTries , self . options . reconnectInterval ) ) ) ; } else { self . reconnectId = setTimeout ( attemptReconnect ( self ) , self . options . reconnectInterval ) ; } } ; }
If we have failure schedule a retry
If we have failure schedule a retry