Skip to content

Commit

Permalink
fix(utils::killProcess): handle case where input could be undefined a…
Browse files Browse the repository at this point in the history
…t runtime

somehow, it can come in undefined, so it needs to be handled

fixes #666
  • Loading branch information
hasezoey committed Jun 22, 2022
1 parent 02452a4 commit 209520f
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions packages/mongodb-memory-server-core/src/util/utils.ts
Expand Up @@ -99,6 +99,13 @@ export async function killProcess(
log(`Mongo[${mongodPort || 'unknown'}] killProcess: ${msg}`);
}

// this case can somehow happen, see https://github.com/nodkz/mongodb-memory-server/issues/666
if (isNullOrUndefined(childprocess)) {
ilog('childprocess was somehow undefined');

return;
}

// check if the childProcess (via PID) is still alive (found thanks to https://github.com/nodkz/mongodb-memory-server/issues/411)
if (!isAlive(childprocess.pid)) {
ilog("given childProcess's PID was not alive anymore");
Expand Down

0 comments on commit 209520f

Please sign in to comment.