Skip to content

Commit 5605ea0

Browse files
committed
fix(utils): killProcess: unify log and variable names with other code
1 parent 31c98c9 commit 5605ea0

File tree

1 file changed

+10
-7
lines changed
  • packages/mongodb-memory-server-core/src/util

1 file changed

+10
-7
lines changed

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

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,13 @@ export async function killProcess(childprocess: ChildProcess, name: string): Pro
7575
return;
7676
}
7777

78+
/**
79+
* Timeout before using SIGKILL
80+
*/
7881
const timeoutTime = 1000 * 10;
79-
await new Promise<void>((resolve, reject) => {
82+
await new Promise<void>((res, rej) => {
8083
let timeout = setTimeout(() => {
81-
log('killProcess timeout triggered, trying SIGKILL');
84+
log('killProcess: timeout triggered, trying SIGKILL');
8285

8386
if (!debug.enabled('MongoMS:utils')) {
8487
console.warn(
@@ -89,16 +92,16 @@ export async function killProcess(childprocess: ChildProcess, name: string): Pro
8992

9093
childprocess.kill('SIGKILL');
9194
timeout = setTimeout(() => {
92-
log('killProcess timeout triggered again, rejecting');
93-
reject(new Error('Process didnt exit, enable debug for more information.'));
95+
log('killProcess: timeout triggered again, rejecting');
96+
rej(new Error(`Process "${name}" didnt exit, enable debug for more information.`));
9497
}, timeoutTime);
9598
}, timeoutTime);
9699
childprocess.once(`exit`, (code, signal) => {
97-
log(`- ${name}: got exit signal, Code: ${code}, Signal: ${signal}`);
100+
log(`killProcess: ${name}: got exit signal, Code: ${code}, Signal: ${signal}`);
98101
clearTimeout(timeout);
99-
resolve();
102+
res();
100103
});
101-
log(`- ${name}: send "SIGINT"`);
104+
log(`killProcess: ${name}: sending "SIGINT"`);
102105
childprocess.kill('SIGINT');
103106
});
104107
}

0 commit comments

Comments
 (0)