Skip to content

Commit b8042e1

Browse files
Merge pull request #245 from Sebastian-Webster/242-database-fails-to-be-killed-and-deleted-on-windows-with-node-23x
Fix failures on Windows with Node 23.x
2 parents d36dd30 + faed73c commit b8042e1

File tree

5 files changed

+38
-23
lines changed

5 files changed

+38
-23
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@ jobs:
2323
run: npm ci
2424

2525
- name: Run tests
26-
run: npm run test
26+
run: npm run test:ci
2727

2828
- name: Move MySQLMSN directory for GitHub Actions upload
2929
if: ${{ failure() }}
3030
env:
3131
MOVE_MYSQLMSN_TO: /tmp/mysqlmsn
3232
run: npx ts-node tests/ci/DirMoveGitHubActions.ts
3333

34-
- name: Upload mysqlmsn directory (Not Windows)
34+
- name: Upload mysqlmsn directory
3535
if: ${{ failure() }}
3636
uses: actions/[email protected]
3737
with:

.github/workflows/node-compatibility.yml

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,17 @@ on:
88

99
jobs:
1010
node:
11-
runs-on: ubuntu-latest
11+
runs-on: ${{ matrix.os }}
1212

1313
strategy:
1414
fail-fast: false
1515
matrix:
16+
os: [macos-14, macos-15, macos-15-intel, macos-26, ubuntu-22.04, ubuntu-24.04, windows-2022, windows-2025, ubuntu-22.04-arm, ubuntu-24.04-arm, windows-11-arm]
1617
node-version: [18.x, 19.x, 20.x, 21.x, 22.x, 23.x, 24.x, 25.x]
18+
# Exclude Node 18.x on Windows on Arm because Node only provides Windows on Arm binaries for Node >= 19
19+
exclude:
20+
- os: windows-11-arm
21+
node-version: 18.x
1722

1823
steps:
1924
- name: Checkout
@@ -31,10 +36,16 @@ jobs:
3136
- name: Run tests
3237
run: npm run test:ci
3338

39+
- name: Move MySQLMSN directory for GitHub Actions upload
40+
if: ${{ failure() }}
41+
env:
42+
MOVE_MYSQLMSN_TO: ${{ runner.os == 'Windows' && 'C:\\Users\\RUNNER~1\\mysqlmsn' || '/tmp/mysqlmsn' }}
43+
run: npx ts-node tests/ci/DirMoveGitHubActions.ts
44+
3445
- name: Upload mysqlmsn directory
3546
if: ${{ failure() }}
3647
uses: actions/[email protected]
3748
with:
3849
name: node-${{ matrix.node-version }}
39-
path: /tmp/mysqlmsn
50+
path: ${{ runner.os == 'Windows' && 'C:\\Users\\RUNNER~1\\mysqlmsn' || '/tmp/mysqlmsn' }}
4051
compression-level: 9

.github/workflows/old-node-tests.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,14 @@ on:
88

99
jobs:
1010
node:
11-
runs-on: ubuntu-latest
11+
runs-on: ${{ matrix.os }}
1212

1313
strategy:
1414
fail-fast: false
1515
matrix:
1616
node-version: [16.6.0, 16.x, 17.0.0, 17.x]
17+
# windows-11-arm is not included here because Node only has Windows on Arm binaries for Node >= 19
18+
os: [macos-14, macos-15, macos-15-intel, macos-26, ubuntu-22.04, ubuntu-24.04, windows-2022, windows-2025, ubuntu-22.04-arm, ubuntu-24.04-arm]
1719

1820
steps:
1921
- name: Checkout
@@ -31,10 +33,16 @@ jobs:
3133
- name: Run tests
3234
run: npx ts-node tests/old-node.ts
3335

36+
- name: Move MySQLMSN directory for GitHub Actions upload
37+
if: ${{ failure() }}
38+
env:
39+
MOVE_MYSQLMSN_TO: ${{ runner.os == 'Windows' && 'C:\\Users\\RUNNER~1\\mysqlmsn' || '/tmp/mysqlmsn' }}
40+
run: npx ts-node tests/ci/DirMoveGitHubActions.ts
41+
3442
- name: Upload mysqlmsn directory
3543
if: ${{ failure() }}
3644
uses: actions/[email protected]
3745
with:
3846
name: node-${{ matrix.node-version }}
39-
path: /tmp/mysqlmsn
47+
path: ${{ runner.os == 'Windows' && 'C:\\Users\\RUNNER~1\\mysqlmsn' || '/tmp/mysqlmsn' }}
4048
compression-level: 9

.github/workflows/os-compatibility.yml

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,12 @@ jobs:
4141
MOVE_MYSQLMSN_TO: ${{ runner.os == 'Windows' && 'C:\\Users\\RUNNER~1\\mysqlmsn' || '/tmp/mysqlmsn' }}
4242
run: npx ts-node tests/ci/DirMoveGitHubActions.ts
4343

44-
- name: Upload mysqlmsn directory (Windows)
45-
if: ${{ failure() && runner.os == 'Windows' }}
46-
uses: actions/[email protected]
47-
with:
48-
name: ${{ matrix.os }}-${{ matrix.version-requirement }}
49-
path: "C:\\Users\\RUNNER~1\\mysqlmsn"
50-
compression-level: 9
51-
52-
- name: Upload mysqlmsn directory (Not Windows)
53-
if: ${{ failure() && runner.os != 'Windows' }}
44+
- name: Upload mysqlmsn directory
45+
if: ${{ failure() }}
5446
uses: actions/[email protected]
5547
with:
56-
name: ${{ matrix.os }}-${{ matrix.version-requirement }}
57-
path: /tmp/mysqlmsn
48+
name: node-${{ matrix.node-version }}
49+
path: ${{ runner.os == 'Windows' && 'C:\\Users\\RUNNER~1\\mysqlmsn' || '/tmp/mysqlmsn' }}
5850
compression-level: 9
5951

6052
fedora-docker:

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)