From ee5398368e419de9aa11207dcfa330c262dbfdf0 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Mon, 7 Oct 2019 21:19:23 -0400 Subject: [PATCH] fix(mongos): disconnect proxies which are not mongos instances NODE-2232 --- lib/core/topologies/mongos.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/core/topologies/mongos.js b/lib/core/topologies/mongos.js index 5164e07897..f7b8db3a2f 100644 --- a/lib/core/topologies/mongos.js +++ b/lib/core/topologies/mongos.js @@ -366,7 +366,8 @@ function handleInitialConnectEvent(self, event) { self.s.logger.warn(f(message, _this.name)); } - // This is not a mongos proxy, remove it completely + // This is not a mongos proxy, destroy and remove it completely + _this.destroy(true); removeProxyFrom(self.connectingProxies, _this); // Emit the left event self.emit('left', 'server', _this); @@ -445,10 +446,9 @@ function connectProxies(self, servers) { server.connect(self.s.connectOptions); }, timeoutInterval); } + // Start all the servers - while (servers.length > 0) { - connect(servers.shift(), timeoutInterval++); - } + servers.forEach(server => connect(server, timeoutInterval++)); } function pickProxy(self, session) {