mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
Clean up Windows smoke relay shutdown
This commit is contained in:
1
.github/workflows/desktop-release.yml
vendored
1
.github/workflows/desktop-release.yml
vendored
@@ -443,6 +443,7 @@ jobs:
|
||||
exit 1
|
||||
|
||||
- name: Smoke check managed runtime for Windows
|
||||
timeout-minutes: 12
|
||||
env:
|
||||
PASEO_MANAGED_SMOKE_SKIP_BUILD: "1"
|
||||
run: npm run smoke:managed-daemon --workspace=@getpaseo/desktop
|
||||
|
||||
@@ -110,6 +110,19 @@ function escapeForRegExp(value) {
|
||||
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
||||
}
|
||||
|
||||
async function waitForChildExit(child, timeoutMs) {
|
||||
if (!child || child.exitCode !== null || child.killed) {
|
||||
return;
|
||||
}
|
||||
await new Promise((resolve) => {
|
||||
const timeout = setTimeout(resolve, timeoutMs);
|
||||
child.once("exit", () => {
|
||||
clearTimeout(timeout);
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function execFileWithTimeout(command, args, options, label) {
|
||||
try {
|
||||
return await execFileAsync(command, args, {
|
||||
@@ -141,6 +154,34 @@ async function runBinary(binaryPath, args, env) {
|
||||
};
|
||||
}
|
||||
|
||||
async function terminateChildProcess(child, label) {
|
||||
if (!child || child.exitCode !== null || child.killed) {
|
||||
return;
|
||||
}
|
||||
if (process.platform === "win32" && typeof child.pid === "number") {
|
||||
try {
|
||||
await execFileWithTimeout(
|
||||
"taskkill",
|
||||
["/pid", String(child.pid), "/T", "/F"],
|
||||
{ maxBuffer: 1024 * 1024 },
|
||||
`${label} taskkill`
|
||||
);
|
||||
} catch {}
|
||||
await waitForChildExit(child, 5_000);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
child.kill("SIGTERM");
|
||||
} catch {}
|
||||
await waitForChildExit(child, 5_000);
|
||||
if (child.exitCode === null && !child.killed) {
|
||||
try {
|
||||
child.kill("SIGKILL");
|
||||
} catch {}
|
||||
await waitForChildExit(child, 5_000);
|
||||
}
|
||||
}
|
||||
|
||||
async function runWorkspaceCli(args, env) {
|
||||
const { stdout, stderr } = await execFileWithTimeout(
|
||||
process.execPath,
|
||||
@@ -808,6 +849,6 @@ try {
|
||||
}
|
||||
} catch {}
|
||||
try {
|
||||
relayProcess?.kill("SIGTERM");
|
||||
await terminateChildProcess(relayProcess, "local relay");
|
||||
} catch {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user