Skip to content

Commit

Permalink
fix: don't reset monitor if we aren't streaming topology changes
Browse files Browse the repository at this point in the history
A race condition exists when resetting the server monitor during
an existing server check. The reset is not required when we are
not streaming topology changes, so the fix is to no-op in that
condition.

NODE-2876
  • Loading branch information
mbroadst committed Nov 10, 2020
1 parent 66dcfea commit a10171b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/core/sdam/monitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,8 @@ class Monitor extends EventEmitter {
}

reset() {
if (isInCloseState(this)) {
const topologyVersion = this[kServer].description.topologyVersion;
if (isInCloseState(this) || topologyVersion == null) {
return;
}

Expand Down Expand Up @@ -152,7 +153,6 @@ class Monitor extends EventEmitter {
}

function resetMonitorState(monitor) {
stateTransition(monitor, STATE_CLOSING);
if (monitor[kMonitorId]) {
monitor[kMonitorId].stop();
monitor[kMonitorId] = null;
Expand Down

0 comments on commit a10171b

Please sign in to comment.