From 44db87a33924838065b680ffca11c445eb8b2fbd Mon Sep 17 00:00:00 2001 From: Durran Jordan Date: Tue, 27 Apr 2021 14:01:56 +0200 Subject: [PATCH] fix(sdam): topology no longer causes close event The topology was emitting both a "topologyClosed" and "close" event which are bubbled up to the MongoClient. This was causing two "close" events to be emitted from the MongoClient when the client is closed. NODE-3219 --- lib/core/sdam/topology.js | 1 - test/functional/operation_example.test.js | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/core/sdam/topology.js b/lib/core/sdam/topology.js index f18f7785c85..1ca73ee48ab 100644 --- a/lib/core/sdam/topology.js +++ b/lib/core/sdam/topology.js @@ -359,7 +359,6 @@ class Topology extends EventEmitter { this.emit('topologyClosed', new events.TopologyClosedEvent(this.s.id)); stateTransition(this, STATE_CLOSED); - this.emit('close'); if (typeof callback === 'function') { callback(err); diff --git a/test/functional/operation_example.test.js b/test/functional/operation_example.test.js index 34e87c5ddf4..a4db0658ded 100644 --- a/test/functional/operation_example.test.js +++ b/test/functional/operation_example.test.js @@ -3688,10 +3688,9 @@ describe('Operation Examples', function() { // REMOVE-LINE done(); // REMOVE-LINE var db = client.db(configuration.db); // BEGIN - var db = client.db(configuration.db); test.equal(null, err); - db.on('close', function() { + client.on('close', function() { done(); });