Skip to content

Commit 918a1e0

Browse files
simllllmbroadst
authored andcommitted
fix(connect): correct replacement of topology on connect callback
if topology.connect has an error, topology is "overwritten", changing the function parameter to a new name, let's "force close" the old instance.
1 parent 79da11f commit 918a1e0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lib/operations/mongo_client_ops.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -407,14 +407,14 @@ function createTopology(mongoClient, topologyType, options, callback) {
407407
relayEvents(mongoClient, topology);
408408

409409
// Open the connection
410-
topology.connect(options, (err, topology) => {
410+
topology.connect(options, (err, newTopology) => {
411411
if (err) {
412412
topology.close(true);
413413
return callback(err);
414414
}
415415

416-
assignTopology(mongoClient, topology);
417-
callback(null, topology);
416+
assignTopology(mongoClient, newTopology);
417+
callback(null, newTopology);
418418
});
419419
}
420420

0 commit comments

Comments
 (0)