Skip to content

Commit 89eafde

Browse files
committed
do not leak the timeout also in normal path finally block
1 parent a4caf38 commit 89eafde

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/sdam/topology.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
594594
);
595595
}
596596

597-
if (!options.timeoutContext || options.timeoutContext?.clearServerSelectionTimeout) {
597+
if (!options.timeoutContext || options.timeoutContext.clearServerSelectionTimeout) {
598598
timeout?.clear();
599599
}
600600

@@ -668,7 +668,9 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
668668
throw error;
669669
} finally {
670670
abortListener?.[kDispose]();
671-
if (options.timeoutContext?.clearServerSelectionTimeout) timeout?.clear();
671+
if (!options.timeoutContext || options.timeoutContext.clearServerSelectionTimeout) {
672+
timeout?.clear();
673+
}
672674
}
673675
}
674676
/**

0 commit comments

Comments
 (0)