Start a new topic

Searching for records in user collection erratically returns an error

my onPreSave BL is searching for an existing username in user collection with:

modules.collectionAccess.collection('user').findOne({"username": request.username}, function(err, user) {

if (!user) {

logger.fatal(request.username + ' not found');


} else {




Every few saves from the same user, I get an error (null user returned by findOne).

When findOne fails to return an existing user, the mongodb error is "Error: No replica set primary available for query with ReadPreference PRIMARY". Maybe it's a problem with the node driver?
As mentionned by Ivan Stoyanov in another post - how do ref them? - retrying the query when returned user is null does solve the issue.
Login or Signup to post a comment