1

myFunc() is triggered every minute by the timer. The find() not executing callback second trigger onwards. I am expecting an error atleast

function myFunc() {
    let users = schemaMap.get('users');
    users.find({}, function (err, docs) {
        if(err) logger.error(err);
        logger.info('Mongo users: '+docs);
        mongoose.connection.close();
        //mongoose.disconnect();
    });
    ...
}
Visv M
  • 431
  • 4
  • 13

1 Answers1

1

Mongoose will queue up collection actions until the connection is opened.

If you want to disable command buffering:

mongoose.set('bufferCommands', false);
JohnnyHK
  • 305,182
  • 66
  • 621
  • 471