From 45ac09a89d3f7f7e2bcdb6cbe9b27dcf5b09fe26 Mon Sep 17 00:00:00 2001 From: Matt Broadstone Date: Fri, 27 Sep 2019 14:53:00 -0400 Subject: [PATCH] fix(replset): destroy primary before removing from replsetstate --- lib/core/topologies/replset.js | 2 ++ test/runner/plugins/client_leak_checker.js | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/lib/core/topologies/replset.js b/lib/core/topologies/replset.js index 2e436abf27..a5c58bffd4 100644 --- a/lib/core/topologies/replset.js +++ b/lib/core/topologies/replset.js @@ -1207,6 +1207,7 @@ function executeWriteOperation(args, options, callback) { // Per SDAM, remove primary from replicaset if (self.s.replicaSetState.primary) { + self.s.replicaSetState.primary.destroy(); self.s.replicaSetState.remove(self.s.replicaSetState.primary, { force: true }); } @@ -1368,6 +1369,7 @@ ReplSet.prototype.command = function(ns, cmd, options, callback) { // Per SDAM, remove primary from replicaset if (this.s.replicaSetState.primary) { + this.s.replicaSetState.primary.destroy(); this.s.replicaSetState.remove(this.s.replicaSetState.primary, { force: true }); } diff --git a/test/runner/plugins/client_leak_checker.js b/test/runner/plugins/client_leak_checker.js index f30f1d0d5a..1ab2857ae6 100644 --- a/test/runner/plugins/client_leak_checker.js +++ b/test/runner/plugins/client_leak_checker.js @@ -26,3 +26,9 @@ afterEach(() => { }); after(() => wtfnode.dump()); + +require('leaked-handles').set({ + fullStack: true, // use full stack traces + timeout: 30000, // run every 30 seconds instead of 5. + debugSockets: true // pretty print tcp thrown exceptions. +});