Skip to content

Commit

Permalink
fix(MongoMemoryReplSet::_initReplSet): use "extraConnectionOptions" w…
Browse files Browse the repository at this point in the history
…hen "_ranCreateAuth" is "true"
  • Loading branch information
hasezoey committed Aug 17, 2022
1 parent 2fc87e7 commit e116128
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/mongodb-memory-server-core/src/MongoMemoryReplSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -674,9 +674,14 @@ export class MongoMemoryReplSet extends EventEmitter implements ManagerAdvanced
const uris = this.servers.map((server) => server.getUri());
const isInMemory = this.servers[0].instanceInfo?.storageEngine === 'ephemeralForTest';

const extraOptions = this._ranCreateAuth
? this.servers[0].instanceInfo?.instance.extraConnectionOptions ?? {}
: {};

const con: MongoClient = await MongoClient.connect(uris[0], {
// somehow since mongodb-nodejs 4.0, this option is needed when the server is set to be in a replset
directConnection: true,
...extraOptions,
});
log('_initReplSet: connected');

Expand Down

0 comments on commit e116128

Please sign in to comment.