Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
feat(replset): more verbose replica set errors emission
Browse files Browse the repository at this point in the history
Port of #231 to 3.0.0.
When a replica set topology has an invalid name, core emits an error
stating that no primary or secondary found in the replica set, which can
cause some user confusion. This simply expands the language to include
that the name may be invalid to help with debugging.
  • Loading branch information
daprahamian authored and mbroadst committed Nov 20, 2017
1 parent eaa111a commit 6d5eccd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/topologies/replset.js
Original file line number Diff line number Diff line change
Expand Up @@ -636,14 +636,14 @@ function topologyMonitor(self, options) {

if (!self.s.replicaSetState.hasPrimary() && !self.s.options.secondaryOnlyConnectionAllowed) {
if (err) return self.emit('error', err);
self.emit('error', new MongoError('no primary found in replicaset'));
self.emit('error', new MongoError('no primary found in replicaset or invalid replica set name'));
return self.destroy({ force: true });
} else if (
!self.s.replicaSetState.hasSecondary() &&
self.s.options.secondaryOnlyConnectionAllowed
) {
if (err) return self.emit('error', err);
self.emit('error', new MongoError('no secondary found in replicaset'));
self.emit('error', new MongoError('no secondary found in replicaset or invalid replica set name'));
return self.destroy({ force: true });
}

Expand Down

0 comments on commit 6d5eccd

Please sign in to comment.