Skip to content

Commit

Permalink
fix(close): the unified topology emits a close event on close now
Browse files Browse the repository at this point in the history
  • Loading branch information
mbroadst committed Nov 5, 2019
1 parent 0b7788e commit ee0db01
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/operations/close.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
const Aspect = require('./operation').Aspect;
const defineAspects = require('./operation').defineAspects;
const OperationBase = require('./operation').OperationBase;
const NativeTopology = require('../topologies/native_topology');

class CloseOperation extends OperationBase {
constructor(client, force) {
Expand All @@ -16,8 +17,11 @@ class CloseOperation extends OperationBase {
const force = this.force;
const completeClose = err => {
client.emit('close', client);
for (const item of client.s.dbCache) {
item[1].emit('close', client);

if (!(client.topology instanceof NativeTopology)) {
for (const item of client.s.dbCache) {
item[1].emit('close', client);
}
}

client.removeAllListeners('close');
Expand Down

0 comments on commit ee0db01

Please sign in to comment.