fix: stabilize macos daemon onboarding

This commit is contained in:
Peter Steinberger
2026-03-13 13:46:35 +00:00
parent 0a3b9a9a09
commit 80e7da92ce
5 changed files with 49 additions and 6 deletions

View File

@@ -250,7 +250,7 @@ describe("launchd install", () => {
};
}
it("enables service before bootstrap (clears persisted disabled state)", async () => {
it("enables service before bootstrap without self-restarting the fresh agent", async () => {
const env = createDefaultLaunchdEnv();
await installLaunchAgent({
env,
@@ -269,9 +269,13 @@ describe("launchd install", () => {
const bootstrapIndex = state.launchctlCalls.findIndex(
(c) => c[0] === "bootstrap" && c[1] === domain && c[2] === plistPath,
);
const installKickstartIndex = state.launchctlCalls.findIndex(
(c) => c[0] === "kickstart" && c[2] === serviceId,
);
expect(enableIndex).toBeGreaterThanOrEqual(0);
expect(bootstrapIndex).toBeGreaterThanOrEqual(0);
expect(enableIndex).toBeLessThan(bootstrapIndex);
expect(installKickstartIndex).toBe(-1);
});
it("writes TMPDIR to LaunchAgent environment when provided", async () => {

View File

@@ -431,7 +431,9 @@ export async function installLaunchAgent({
}
throw new Error(`launchctl bootstrap failed: ${detail}`);
}
await execLaunchctl(["kickstart", "-k", `${domain}/${label}`]);
// `bootstrap` already loads RunAtLoad agents. Avoid `kickstart -k` here:
// on slow macOS guests it SIGTERMs the freshly booted gateway and pushes the
// real listener startup past onboarding's health deadline.
// Ensure we don't end up writing to a clack spinner line (wizards show progress without a newline).
writeFormattedLines(