Skip to content

Commit

Permalink
fix(sdam): topology no longer causes close event (#2791)
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 29, 2021
1 parent 971259a commit 16e7064
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
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
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 16e7064

Please sign in to comment.