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 495e86b commit 2f23dd7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/sdam/monitor.ts
Expand Up @@ -138,7 +138,8 @@ export class Monitor extends EventEmitter {
}

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

Expand Down Expand Up @@ -172,7 +173,6 @@ export class Monitor extends EventEmitter {
}

function resetMonitorState(monitor: Monitor) {
stateTransition(monitor, STATE_CLOSING);
monitor[kMonitorId]?.stop();
monitor[kMonitorId] = undefined;

Expand Down

0 comments on commit 2f23dd7

Please sign in to comment.