Summary
In src/daemon.rs, two cleanup paths currently silently discard remove_file errors, making stale PID/socket problems harder to diagnose on the next launch:
unix_impl::cleanup_stale_files – uses bare let _ = std::fs::remove_file(...) for both the PID file and the socket file.
- The
tokio::spawn shutdown task in unix_impl::start_ipc_server – uses let _ = std::fs::remove_file(&cleanup_socket) after the shutdown signal is received.
Per the project coding guidelines (AGENTS.md): Don't silently discard errors. No let _ = on Results. Handle them, log them, or propagate them.
Suggested fix
tokio::spawn(async move {
let _ = cleanup_rx.wait_for(|shutdown| *shutdown).await;
- let _ = std::fs::remove_file(&cleanup_socket);
+ if let Err(error) = std::fs::remove_file(&cleanup_socket)
+ && error.kind() != std::io::ErrorKind::NotFound
+ {
+ tracing::warn!(
+ %error,
+ path = %cleanup_socket.display(),
+ "failed to remove IPC socket on shutdown"
+ );
+ }
});
fn cleanup_stale_files(paths: &DaemonPaths) {
- let _ = std::fs::remove_file(&paths.pid_file);
- let _ = std::fs::remove_file(&paths.socket);
+ for path in [&paths.pid_file, &paths.socket] {
+ if let Err(error) = std::fs::remove_file(path)
+ && error.kind() != std::io::ErrorKind::NotFound
+ {
+ tracing::warn!(%error, path = %path.display(), "failed to remove stale daemon file");
+ }
+ }
}
Context
Summary
In
src/daemon.rs, two cleanup paths currently silently discardremove_fileerrors, making stale PID/socket problems harder to diagnose on the next launch:unix_impl::cleanup_stale_files– uses barelet _ = std::fs::remove_file(...)for both the PID file and the socket file.tokio::spawnshutdown task inunix_impl::start_ipc_server– useslet _ = std::fs::remove_file(&cleanup_socket)after the shutdown signal is received.Per the project coding guidelines (
AGENTS.md): Don't silently discard errors. Nolet _ =on Results. Handle them, log them, or propagate them.Suggested fix
tokio::spawn(async move { let _ = cleanup_rx.wait_for(|shutdown| *shutdown).await; - let _ = std::fs::remove_file(&cleanup_socket); + if let Err(error) = std::fs::remove_file(&cleanup_socket) + && error.kind() != std::io::ErrorKind::NotFound + { + tracing::warn!( + %error, + path = %cleanup_socket.display(), + "failed to remove IPC socket on shutdown" + ); + } }); fn cleanup_stale_files(paths: &DaemonPaths) { - let _ = std::fs::remove_file(&paths.pid_file); - let _ = std::fs::remove_file(&paths.socket); + for path in [&paths.pid_file, &paths.socket] { + if let Err(error) = std::fs::remove_file(path) + && error.kind() != std::io::ErrorKind::NotFound + { + tracing::warn!(%error, path = %path.display(), "failed to remove stale daemon file"); + } + } }Context
cleanup_stale_fileslogic was pre-existing Unix-only code; this PR (fix(windows,desktop): sidecar launch fixes and dev mode support #558) only reorganised it intounix_implwithout changing its logic. Improving it was intentionally deferred to keep that PR's scope focused on Windows/sidecar fixes.