From 619d1fab5cece44865e40261bab9313027dbe44f Mon Sep 17 00:00:00 2001 From: hasezoey Date: Fri, 25 Nov 2022 18:20:09 +0100 Subject: [PATCH] fix(MongoInstance): move getting / downloading the binary before creating the launchTimeout fixes #719 --- .../mongodb-memory-server-core/src/util/MongoInstance.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/mongodb-memory-server-core/src/util/MongoInstance.ts b/packages/mongodb-memory-server-core/src/util/MongoInstance.ts index 954c7de56..4b409c9d7 100644 --- a/packages/mongodb-memory-server-core/src/util/MongoInstance.ts +++ b/packages/mongodb-memory-server-core/src/util/MongoInstance.ts @@ -345,6 +345,9 @@ export class MongoInstance extends EventEmitter implements ManagerBase { let timeout: NodeJS.Timeout; + const mongoBin = await MongoBinary.getPath(this.binaryOpts); + await checkBinaryPermissions(mongoBin); + const launch: Promise = new Promise((res, rej) => { this.once(MongoInstanceEvents.instanceReady, res); this.once(MongoInstanceEvents.instanceError, rej); @@ -369,8 +372,6 @@ export class MongoInstance extends EventEmitter implements ManagerBase { clearTimeout(timeout); }); - const mongoBin = await MongoBinary.getPath(this.binaryOpts); - await checkBinaryPermissions(mongoBin); this.debug('start: Starting Processes'); this.mongodProcess = this._launchMongod(mongoBin); // This assertion is here because somewhere between nodejs 12 and 16 the types for "childprocess.pid" changed to include "| undefined"