diff --git a/lib/storage/metadata/mongoclient/MongoClientInterface.js b/lib/storage/metadata/mongoclient/MongoClientInterface.js index 8bf6cf10c..c29e87728 100644 --- a/lib/storage/metadata/mongoclient/MongoClientInterface.js +++ b/lib/storage/metadata/mongoclient/MongoClientInterface.js @@ -91,7 +91,7 @@ class MongoClientInterface { constructor(params) { const { replicaSetHosts, writeConcern, replicaSet, readPreference, path, database, logger, replicationGroupId, authCredentials, - isLocationTransient, shardCollections } = params; + isLocationTransient, shardCollections, useUnifiedTopology } = params; const cred = MongoUtils.credPrefix(authCredentials); this.mongoUrl = `mongodb://${cred}${replicaSetHosts}/` + `?w=${writeConcern}&readPreference=${readPreference}`; @@ -108,6 +108,7 @@ class MongoClientInterface { this.database = database; this.isLocationTransient = isLocationTransient; this.shardCollections = shardCollections; + this.useUnifiedTopology = useUnifiedTopology; this.concurrentCursors = (process.env.CONCURRENT_CURSORS && !Number.isNaN(process.env.CONCURRENT_CURSORS)) @@ -144,6 +145,9 @@ class MongoClientInterface { socketTimeoutMS, useNewUrlParser: true, }; + if (this.useUnifiedTopology === true) { + options.useUnifiedTopology = true; + } if (process.env.MONGO_POOL_SIZE && !Number.isNaN(process.env.MONGO_POOL_SIZE)) { options.poolSize = Number.parseInt(process.env.MONGO_POOL_SIZE, 10); diff --git a/package.json b/package.json index ce46184df..39c36c4e9 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "engines": { "node": ">=16" }, - "version": "8.1.113", + "version": "8.1.114", "description": "Common utilities for the S3 project components", "main": "build/index.js", "repository": {