Skip to content

Commit a10171b

Browse files
committed
fix: don't reset monitor if we aren't streaming topology changes
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
1 parent 66dcfea commit a10171b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/core/sdam/monitor.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ class Monitor extends EventEmitter {
118118
}
119119

120120
reset() {
121-
if (isInCloseState(this)) {
121+
const topologyVersion = this[kServer].description.topologyVersion;
122+
if (isInCloseState(this) || topologyVersion == null) {
122123
return;
123124
}
124125

@@ -152,7 +153,6 @@ class Monitor extends EventEmitter {
152153
}
153154

154155
function resetMonitorState(monitor) {
155-
stateTransition(monitor, STATE_CLOSING);
156156
if (monitor[kMonitorId]) {
157157
monitor[kMonitorId].stop();
158158
monitor[kMonitorId] = null;

0 commit comments

Comments
 (0)