fix: recover unloaded macOS launch agents (#43766)

This commit is contained in:
Peter Steinberger
2026-04-05 09:01:05 +01:00
parent 07e7b7177f
commit fd968bfb2d
8 changed files with 276 additions and 15 deletions

View File

@@ -325,7 +325,12 @@ export async function repairLaunchAgentBootstrap(args: {
await execLaunchctl(["enable", `${domain}/${label}`]);
const boot = await execLaunchctl(["bootstrap", domain, plistPath]);
if (boot.code !== 0) {
return { ok: false, detail: (boot.stderr || boot.stdout).trim() || undefined };
const detail = (boot.stderr || boot.stdout).trim();
const normalized = detail.toLowerCase();
const alreadyLoaded = boot.code === 130 || normalized.includes("already exists in domain");
if (!alreadyLoaded) {
return { ok: false, detail: detail || undefined };
}
}
const kick = await execLaunchctl(["kickstart", "-k", `${domain}/${label}`]);
if (kick.code !== 0) {