Skip to content

Commit cbe71f9

Browse files
Nepomuk5665sarthaksoni25
authored andcommitted
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 1cf791f commit cbe71f9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/sdam/topology.ts

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

495495
closeCheckedOutConnections() {
496496
for (const server of this.s.servers.values()) {
497-
return server.closeCheckedOutConnections();
497+
server.closeCheckedOutConnections();
498498
}
499499
}
500500

0 commit comments

Comments
 (0)