Skip to content

Commit 84f59a5

Browse files
committed
fix(utils): allow optional parameter and test if undefined (childprocess pid can be undefined)
1 parent 139d567 commit 84f59a5

File tree

1 file changed

+6
-1
lines changed
  • packages/mongodb-memory-server-core/src/util

1 file changed

+6
-1
lines changed

packages/mongodb-memory-server-core/src/util/utils.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,12 @@ export async function killProcess(childprocess: ChildProcess, name: string): Pro
111111
* Check if the given Process is still alive
112112
* @param {number} pid The Process PID
113113
*/
114-
export function isAlive(pid: number): boolean {
114+
export function isAlive(pid?: number): boolean {
115+
// This test (and allow to be undefined) is here because somewhere between nodejs 12 and 16 the types for "childprocess.pid" changed to include "| undefined"
116+
if (isNullOrUndefined(pid)) {
117+
return false;
118+
}
119+
115120
try {
116121
process.kill(pid, 0); // code "0" dosnt actually kill anything (on all supported systems)
117122

0 commit comments

Comments
 (0)