Skip to content

Commit 8be5302

Browse files
committed
fix: restore auto direct connection behavior
1 parent b657c8c commit 8be5302

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/core/uri_parser.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,15 @@ function parseConnectionString(uri, options, callback) {
687687
return callback(new MongoParseError('directConnection option requires exactly one host'));
688688
}
689689

690+
// NOTE: this behavior will go away in v4.0, we will always auto discover there
691+
if (
692+
parsedOptions.directConnection == null &&
693+
hosts.length === 1 &&
694+
parsedOptions.replicaSet == null
695+
) {
696+
parsedOptions.directConnection = true;
697+
}
698+
690699
const result = {
691700
hosts: hosts,
692701
auth: auth.db || auth.username ? auth : null,

0 commit comments

Comments
 (0)