Skip to content

Commit 2f23dd7

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 495e86b commit 2f23dd7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/sdam/monitor.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ export class Monitor extends EventEmitter {
138138
}
139139

140140
reset(): void {
141-
if (isInCloseState(this)) {
141+
const topologyVersion = this[kServer].description.topologyVersion;
142+
if (isInCloseState(this) || topologyVersion == null) {
142143
return;
143144
}
144145

@@ -172,7 +173,6 @@ export class Monitor extends EventEmitter {
172173
}
173174

174175
function resetMonitorState(monitor: Monitor) {
175-
stateTransition(monitor, STATE_CLOSING);
176176
monitor[kMonitorId]?.stop();
177177
monitor[kMonitorId] = undefined;
178178

0 commit comments

Comments
 (0)