Skip to content

Commit e0febfe

Browse files
authored
fix(test): sigkill fallback for stale processes in integration setup (#126)
1 parent 3116b16 commit e0febfe

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

vitest.integration.setup.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ async function killPort(port: number): Promise<void> {
3939
for (const pid of pids) {
4040
process.kill(Number(pid), 'SIGTERM');
4141
}
42-
await new Promise((r) => setTimeout(r, 500));
42+
// Wait for graceful shutdown, then SIGKILL survivors
43+
await new Promise((r) => setTimeout(r, 1000));
44+
for (const pid of pids) {
45+
try { process.kill(Number(pid), 'SIGKILL'); } catch { /* already dead */ }
46+
}
4347
} catch {
4448
// No process on port — nothing to kill
4549
}
@@ -69,7 +73,11 @@ async function killByName(): Promise<void> {
6973
for (const pid of toKill) {
7074
try { process.kill(pid, 'SIGTERM'); } catch { /* already dead */ }
7175
}
72-
await new Promise((r) => setTimeout(r, 500));
76+
// Wait for graceful shutdown, then SIGKILL survivors
77+
await new Promise((r) => setTimeout(r, 1000));
78+
for (const pid of toKill) {
79+
try { process.kill(pid, 'SIGKILL'); } catch { /* already dead */ }
80+
}
7381
} catch {
7482
// pgrep returns exit code 1 when no processes match — expected
7583
}

0 commit comments

Comments
 (0)