Bug Description
When run_module API endpoint creates a service but start_service() fails, the service is left in creating state without cleanup. This leaves orphaned services that:
- Cannot be started (invalid state transition)
- Cannot be stopped (invalid state transition from 'creating' to 'stopping')
- May not be deletable (daemon hangs on delete request)
Root Cause
In fabricksd/src/api/handlers/services.rs lines 282-287:
match manager.create_service(config).await {
Ok(id) => {
// Start the service
if let Err(e) = manager.start_service(&id).await {
return Json(error_response(&e)); // <- Service left in 'creating' state!
}
...
}
...
}
When start_service fails, the code returns an error but doesn't delete the already-created service.
Expected Behavior
If start_service() fails, the service should be cleaned up (deleted) before returning the error.
Proposed Fix
match manager.create_service(config).await {
Ok(id) => {
// Start the service
if let Err(e) = manager.start_service(&id).await {
// Cleanup: delete the service that failed to start
let _ = manager.delete_service(&id).await;
return Json(error_response(&e));
}
...
}
...
}
Reproduction
- Create a WASM module that fails to start (e.g., invalid component)
- Run
fabricks run module:tag
- Observe service stuck in
creating state
fabricks service ls shows the stuck service
fabricks service rm <id> may hang or fail
Impact
This was discovered while implementing JavaScript runtime support (Issue #25).
Bug Description
When
run_moduleAPI endpoint creates a service butstart_service()fails, the service is left increatingstate without cleanup. This leaves orphaned services that:Root Cause
In
fabricksd/src/api/handlers/services.rslines 282-287:When
start_servicefails, the code returns an error but doesn't delete the already-created service.Expected Behavior
If
start_service()fails, the service should be cleaned up (deleted) before returning the error.Proposed Fix
Reproduction
fabricks run module:tagcreatingstatefabricks service lsshows the stuck servicefabricks service rm <id>may hang or failImpact
This was discovered while implementing JavaScript runtime support (Issue #25).