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:
@@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user