From 430e25c31d0d7c5525a0ac057266efa2b0d5f19c Mon Sep 17 00:00:00 2001 From: Dasemu Date: Mon, 16 Nov 2026 19:18:24 +0100 Subject: [PATCH] fix(gui): treat a reset connection to the instance socket as stale Under load, connecting to a socket file whose listener is gone can fail with ECONNRESET instead of ECONNREFUSED; both mean no live instance. Co-Authored-By: Claude Opus 5.5 --- crates/grove-gui/src/instance.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/grove-gui/src/instance.rs b/crates/grove-gui/src/instance.rs index c3b1fa4..f699084 100644 --- a/crates/grove-gui/src/instance.rs +++ b/crates/grove-gui/src/instance.rs @@ -64,14 +64,17 @@ pub fn acquire_with(path: &Path, show: bool, timeout: Duration) -> std::io::Resu for _ in 0..3 { match notify(path, if show { "show" } else { "ping" }, timeout) { Ok(()) => return Ok(Role::Secondary), - // Nobody listens: a stale socket file from a crash is replaced. + // Nobody listens: a stale socket file from a crash is replaced. A reset + // (seen under load on a socket whose listener is gone) means the same. Err(e) if matches!( e.kind(), - std::io::ErrorKind::ConnectionRefused | std::io::ErrorKind::NotFound + std::io::ErrorKind::ConnectionRefused + | std::io::ErrorKind::ConnectionReset + | std::io::ErrorKind::NotFound ) => { - if e.kind() == std::io::ErrorKind::ConnectionRefused { + if e.kind() != std::io::ErrorKind::NotFound { let _ = std::fs::remove_file(path); } }