fix(daemon): suppress EPIPE error in restartLaunchAgent stdout write (#14343)

After a successful launchctl kickstart, the stdout.write() for the
status message may fail with EPIPE if the receiving end has already
closed. Catch and ignore EPIPE specifically; re-throw other errors.

Closes #14234

Co-authored-by: Echo Ito <echoito@MacBook-Air.local>
This commit is contained in:
0xRain
2026-02-12 21:55:29 +08:00
committed by GitHub
parent 7f6f7f598c
commit 21d7203fa9

View File

@@ -460,5 +460,11 @@ export async function restartLaunchAgent({
if (res.code !== 0) {
throw new Error(`launchctl kickstart failed: ${res.stderr || res.stdout}`.trim());
}
stdout.write(`${formatLine("Restarted LaunchAgent", `${domain}/${label}`)}\n`);
try {
stdout.write(`${formatLine("Restarted LaunchAgent", `${domain}/${label}`)}\n`);
} catch (err: unknown) {
if ((err as NodeJS.ErrnoException)?.code !== "EPIPE") {
throw err;
}
}
}