Skip to content

Commit f399d3f

Browse files
committed
fix: iterate all servers in closeCheckedOutConnections()
The method had a premature 'return' inside the for loop, which caused it to only close connections on the first server and exit immediately. This fix removes the return statement so all servers have their checked-out connections closed when MongoClient.close() is called. This bug would affect multi-server topologies (replica sets, sharded clusters) where only the first server's connections would be properly closed.
1 parent 2b2366d commit f399d3f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/sdam/topology.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ export class Topology extends TypedEventEmitter<TopologyEvents> {
495495

496496
closeCheckedOutConnections() {
497497
for (const server of this.s.servers.values()) {
498-
return server.closeCheckedOutConnections();
498+
server.closeCheckedOutConnections();
499499
}
500500
}
501501

0 commit comments

Comments
 (0)