diff --git a/lib/topologies/server.js b/lib/topologies/server.js index 6e86ab19e..54e14163b 100644 --- a/lib/topologies/server.js +++ b/lib/topologies/server.js @@ -312,6 +312,13 @@ var eventHandler = function(self, event) { delete servers[self.id]; } + if (event === 'close') { + // Closing emits a server description changed event going to unknown. + sdam.emitServerDescriptionChanged(self, { + address: self.name, arbiters: [], hosts: [], passives: [], type: 'Unknown' + }); + } + // Reconnect failed return error if(event == 'reconnectFailed') { self.emit('reconnectFailed', err); @@ -331,6 +338,11 @@ var eventHandler = function(self, event) { // Reconnect event, emit the server if(event == 'reconnect') { + // Reconnecting emits a server description changed event going from unknown to the + // current server type. + sdam.emitServerDescriptionChanged(self, { + address: self.name, arbiters: [], hosts: [], passives: [], type: sdam.getTopologyType(self) + }); return self.emit(event, self); }