From 4a0b32d90ef7ef5b30f0657440ce0c82a6e086b7 Mon Sep 17 00:00:00 2001 From: Anders Olsson Date: Mon, 25 May 2026 12:32:07 +0200 Subject: [PATCH] fix(supervisor): StartAck::SpawnFailed surfaces real failures Add StartAck::SpawnFailed(String) so callers can distinguish a successful start from a failed spawn. The Start command arm now sends SpawnFailed on io::Error rather than the misleading Started. handlers.rs maps the new variant to an RpcErrorCode::SpawnFailed JSON-RPC error response. Co-Authored-By: Claude Sonnet 4.6 --- crates/xy-supervisor/src/supervisor.rs | 3 ++- crates/xy/src/daemon/handlers.rs | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/crates/xy-supervisor/src/supervisor.rs b/crates/xy-supervisor/src/supervisor.rs index 8c343e7..42edcf9 100644 --- a/crates/xy-supervisor/src/supervisor.rs +++ b/crates/xy-supervisor/src/supervisor.rs @@ -34,6 +34,7 @@ pub enum SupervisorCmd { pub enum StartAck { Started, AlreadyRunning, + SpawnFailed(String), } #[derive(Debug, PartialEq, Eq)] @@ -141,7 +142,7 @@ impl SupervisorTask { Err(err) => { warn!(name = %self.cfg.name, error = %err, "spawn failed"); self.set_state(ServerState::Failed); - let _ = ack.send(StartAck::Started); + let _ = ack.send(StartAck::SpawnFailed(err.to_string())); } } } diff --git a/crates/xy/src/daemon/handlers.rs b/crates/xy/src/daemon/handlers.rs index c5b5938..d331308 100644 --- a/crates/xy/src/daemon/handlers.rs +++ b/crates/xy/src/daemon/handlers.rs @@ -247,6 +247,13 @@ async fn dispatch_lifecycle( match rx.await { Ok(StartAck::Started) => started.push(name), Ok(StartAck::AlreadyRunning) => already.push(name), + Ok(StartAck::SpawnFailed(msg)) => { + return err_response( + id, + RpcErrorCode::SpawnFailed.as_i32(), + format!("failed to start `{name}`: {msg}"), + ); + } Err(_) => { return err_response( id,