From 16ebb5a3fd2e1707c2f7e3f7468333fcb9507b87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=B0=95=EC=84=B1=EC=A4=80?= Date: Thu, 22 Oct 2026 14:09:02 +0900 Subject: [PATCH] Keep the hook server listening after a failed accept or pipe connect macOS: a failed accept() no longer ends the server thread. Transient errors (EINTR, ECONNABORTED) retry at once, others after 100 ms. Windows: a pipe instance whose connect failed is replaced by a fresh one, created before the old one is dropped, so a listening instance always exists. Fixes #853 Co-Authored-By: Claude Opus 5.5 --- NotchBuddy/Sources/App/HookServer.swift | 6 +++++- windows/src-tauri/src/pipe.rs | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/NotchBuddy/Sources/App/HookServer.swift b/NotchBuddy/Sources/App/HookServer.swift index d7ef343707..c7bdde970c 100644 --- a/NotchBuddy/Sources/App/HookServer.swift +++ b/NotchBuddy/Sources/App/HookServer.swift @@ -319,7 +319,11 @@ final class HookServer: @unchecked Sendable { while true { let clientFD = Darwin.accept(fd, nil, nil) - guard clientFD >= 0 else { break } + guard clientFD >= 0 else { + // Never end the server on a failed accept (#853); pause unless it was transient + if errno != EINTR && errno != ECONNABORTED { usleep(100_000) } + continue + } // Reject connections from other users (same-UID check) var euid: uid_t = 0 var egid: gid_t = 0 diff --git a/windows/src-tauri/src/pipe.rs b/windows/src-tauri/src/pipe.rs index 2a6a1d1229..9dbb01bbf4 100644 --- a/windows/src-tauri/src/pipe.rs +++ b/windows/src-tauri/src/pipe.rs @@ -84,6 +84,10 @@ pub fn start(app: AppHandle) { }; loop { if server.connect().await.is_err() { + // A failed instance never connects again (#853): listen on a fresh one. + if let Ok(fresh) = ServerOptions::new().create(&name) { + server = fresh; + } tokio::time::sleep(Duration::from_millis(200)).await; continue; }