From 6385ec49589bf554af6cfb486023fca8d8701ff2 Mon Sep 17 00:00:00 2001 From: Valeri Karpov Date: Wed, 18 Apr 2018 19:39:26 -0400 Subject: [PATCH] fix(mongos): bubble up error events after the first one Re: Automattic/mongoose#6249. Not really sure why this is a `once()` instead of an `on()`, but the current behavior makes it so that subsequent `close` events never make it up to the client, so `db.on('close')` will never get fired if a mongos dies for the 2nd time. --- lib/topologies/mongos.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/topologies/mongos.js b/lib/topologies/mongos.js index 90c0dee9c1..72fb3aa156 100644 --- a/lib/topologies/mongos.js +++ b/lib/topologies/mongos.js @@ -268,9 +268,9 @@ class Mongos extends TopologyBase { }); // Set up listeners - self.s.coreTopology.once('timeout', errorHandler('timeout')); - self.s.coreTopology.once('error', errorHandler('error')); - self.s.coreTopology.once('close', errorHandler('close')); + self.s.coreTopology.on('timeout', errorHandler('timeout')); + self.s.coreTopology.on('error', errorHandler('error')); + self.s.coreTopology.on('close', errorHandler('close')); // Set up serverConfig listeners self.s.coreTopology.on('fullsetup', function() {