Skip to content

Commit

Permalink
fix(sdam): topology no longer causes close event
Browse files Browse the repository at this point in the history
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
  • Loading branch information
durran committed Apr 27, 2021
1 parent 2b18411 commit 44db87a
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 3 deletions.
1 change: 0 additions & 1 deletion lib/core/sdam/topology.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions test/functional/operation_example.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand Down

0 comments on commit 44db87a

Please sign in to comment.