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 <noreply@anthropic.com>
This commit is contained in:
2026-05-25 12:32:07 +02:00
parent b366df0482
commit 4a0b32d90e
2 changed files with 9 additions and 1 deletions
+2 -1
View File
@@ -34,6 +34,7 @@ pub enum SupervisorCmd {
pub enum StartAck {
Started,
AlreadyRunning,
SpawnFailed(String),
}
#[derive(Debug, PartialEq, Eq)]
@@ -141,7 +142,7 @@ impl<S: Spawner> SupervisorTask<S> {
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()));
}
}
}
+7
View File
@@ -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,