From c003c23df7ca20cea54360d6c4cec988212481a0 Mon Sep 17 00:00:00 2001 From: nodkz Date: Tue, 7 Nov 2017 14:12:55 +0600 Subject: [PATCH] fix(MemoryServer): use instance.kill() instead of childProcess.kill() --- src/MongoMemoryServer.js | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/MongoMemoryServer.js b/src/MongoMemoryServer.js index 25b6a519d..726dfafa9 100644 --- a/src/MongoMemoryServer.js +++ b/src/MongoMemoryServer.js @@ -145,15 +145,10 @@ export default class MongoMemoryServer { } async stop(): Promise { - const { childProcess, port, tmpDir } = (await this.getInstanceData(): MongoInstanceDataT); + const { instance, port, tmpDir } = (await this.getInstanceData(): MongoInstanceDataT); - if (childProcess && childProcess.kill) { - this.debug(`Shutdown MongoDB server on port ${port} with pid ${childProcess.pid}`); - await new Promise(resolve => { - childProcess.once(`exit`, resolve); - childProcess.kill(); - }); - } + this.debug(`Shutdown MongoDB server on port ${port} with pid ${instance.getPid() || ''}`); + await instance.kill(); if (tmpDir) { this.debug(`Removing tmpDir ${tmpDir.name}`);