Skip to content

Commit 3a55d9d

Browse files
Fix failures on Windows with Node 23.x
1 parent 6f0976f commit 3a55d9d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/libraries/Executor.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,19 @@ class Executor {
3535
})
3636
}
3737

38-
async #killProcess(process: ChildProcess): Promise<boolean> {
38+
async #killProcess(childProcess: ChildProcess): Promise<boolean> {
3939
// If the process has already been killed, return true
40-
if (process.kill(0) === false) {
41-
this.logger.warn('Called #killProcess to kill mysqld but it has already been killed.')
40+
const pid = childProcess.pid
41+
42+
try {
43+
process.kill(pid, 0)
44+
} catch (e) {
45+
this.logger.warn('#killProcess got called to kill mysqld but it is not running:', e)
4246
return true
4347
}
4448

4549
if (os.platform() === 'win32') {
46-
const {error, stderr} = await this.#executeFile('taskkill', ['/pid', String(process.pid), '/t', '/f'])
50+
const {error, stderr} = await this.#executeFile('taskkill', ['/pid', String(pid), '/t', '/f'])
4751
const message = error || stderr
4852

4953
if (!message) {
@@ -59,7 +63,7 @@ class Executor {
5963
return false
6064
}
6165

62-
return process.kill('SIGKILL')
66+
return process.kill(pid, 'SIGKILL')
6367
}
6468

6569
//Returns a path to the binary if it should be deleted

0 commit comments

Comments
 (0)