fix: truly detach Windows update batch via spawn+unref instead of exec
All checks were successful
Build & Release / build (push) Successful in 2m26s

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
MiTHRAL 2026-04-22 01:42:37 -04:00
parent fa4c4db944
commit 213d1d3039

View file

@ -1,5 +1,5 @@
import { Notification, app, ipcMain } from "electron";
import { exec } from "child_process";
import { exec, spawn } from "child_process";
import { createWriteStream, mkdirSync, writeFileSync } from "fs";
import { dirname, join } from "path";
import { tmpdir } from "os";
@ -118,8 +118,13 @@ async function downloadAndInstall(url: string, version: string) {
].join("\r\n");
writeFileSync(batchPath, bat);
// Launch batch detached so it outlives this process
exec(`cmd /C start /B "" "${batchPath}"`);
// Spawn batch truly detached so it outlives this process
const child = spawn("cmd.exe", ["/C", batchPath], {
detached: true,
stdio: "ignore",
windowsHide: false,
});
child.unref();
setUpdateReady(version); // restart button will just app.exit(0) — batch relaunches
} else {
await new Promise<void>((resolve, reject) => {