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 <noreply@anthropic.com>
This commit is contained in:
dasemuandClaude Opus 5.5 committed 2026-11-16 19:18:24 +01:00
1 parent 04750532f2
commit 430e25c31d
1 file changed
+6 -3
+6 -3
View File
@@ -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);
}
}