fix: make Windows updater helper launch reliable
ForgeFlow quality gate / quality (push) Canceled after 0s

This commit is contained in:
NuklearRabbit
2026-08-01 17:59:55 +02:00
parent 8fa4891075
commit 958d5b84d3
9 changed files with 107 additions and 28 deletions
+23 -12
View File
@@ -33,6 +33,18 @@ function resolveWindowsPowerShellPath(environment = process.env) {
return "powershell.exe";
}
function windowsUpdaterSpawnOptions(cwd) {
return {
// A detached hidden PowerShell child can exit successfully on Windows
// without ever executing its -File script. Normal Windows children survive
// their parent; unref() below releases the event-loop reference instead.
detached: false,
stdio: "ignore",
windowsHide: true,
cwd,
};
}
async function readJsonFile(filePath) {
try {
return JSON.parse(await fs.readFile(filePath, "utf8"));
@@ -450,12 +462,11 @@ class UpdateService {
const childState = { exited: false, code: null, error: null };
let child;
try {
child = this.spawnProcess(executable, args, {
detached: true,
stdio: "ignore",
windowsHide: true,
cwd: this.sourcePath,
});
child = this.spawnProcess(
executable,
args,
windowsUpdaterSpawnOptions(this.sourcePath),
);
} catch (error) {
error.code ||= "UPDATE_HELPER_SPAWN_FAILED";
throw error;
@@ -591,12 +602,11 @@ class UpdateService {
"-UpdateId",
updateId,
];
const child = this.spawnProcess(executable, args, {
detached: true,
stdio: "ignore",
windowsHide: true,
cwd: this.updateDirectory,
});
const child = this.spawnProcess(
executable,
args,
windowsUpdaterSpawnOptions(this.updateDirectory),
);
const childState = { exited: false, code: null, error: null };
child.once?.("error", (error) => {
childState.error = error;
@@ -700,6 +710,7 @@ module.exports = {
UpdateService,
safeRepositoryPart,
resolveWindowsPowerShellPath,
windowsUpdaterSpawnOptions,
waitForUpdaterStarted,
readJsonFile,
readLogTail,
+1 -1
View File
@@ -5,7 +5,7 @@ function createMockRepositoryBridge(context) {
await wait(80);
snapshot();
return {
appVersion: "0.10.5-demo",
appVersion: "0.10.6-demo",
platform: "win32",
state: clone(state),
git: { available: true, version: "git version 2.47.3" },