fix: make Windows updater helper launch reliable
ForgeFlow quality gate / quality (push) Canceled after 0s
ForgeFlow quality gate / quality (push) Canceled after 0s
This commit is contained in:
+23
-12
@@ -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,
|
||||
|
||||
@@ -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" },
|
||||
|
||||
Reference in New Issue
Block a user