From 21d7203fa91abd914dcc794f0f5a331c1f1a0466 Mon Sep 17 00:00:00 2001 From: 0xRain Date: Thu, 12 Feb 2026 21:55:29 +0800 Subject: [PATCH] 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 --- src/daemon/launchd.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/daemon/launchd.ts b/src/daemon/launchd.ts index a40b7a7e41e..56da87df332 100644 --- a/src/daemon/launchd.ts +++ b/src/daemon/launchd.ts @@ -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; + } + } }