@@ -83,8 +83,8 @@ export interface LaunchdBootstrapResult {
8383 controller : string ;
8484 openclaw : string ;
8585 } ;
86- /** Promise that resolves when controller is ready (for optional awaiting) */
87- controllerReady : Promise < void > ;
86+ /** Promise that always settles with controller readiness outcome. */
87+ controllerReady : Promise < ControllerReadyResult > ;
8888 /** Actual ports used (may differ from requested if OS-assigned or recovered) */
8989 effectivePorts : {
9090 controllerPort : number ;
@@ -95,6 +95,8 @@ export interface LaunchdBootstrapResult {
9595 isAttach : boolean ;
9696}
9797
98+ type ControllerReadyResult = { ok : true } | { ok : false ; error : Error } ;
99+
98100/** Metadata persisted between sessions for attach discovery */
99101interface RuntimePortsMetadata {
100102 writtenAt : string ;
@@ -595,11 +597,20 @@ export async function bootstrapWithLaunchd(
595597 ) ;
596598
597599 // Controller readiness
598- const controllerReady = needsControllerReady
599- ? waitForControllerReadiness ( effectivePorts . controllerPort ) . then ( ( ) =>
600- console . log ( "Controller is ready" ) ,
601- )
602- : Promise . resolve ( ) ;
600+ const controllerReady : Promise < ControllerReadyResult > = needsControllerReady
601+ ? waitForControllerReadiness ( effectivePorts . controllerPort )
602+ . then ( ( ) => {
603+ console . log ( "Controller is ready" ) ;
604+ return { ok : true } as const ;
605+ } )
606+ . catch ( ( error : unknown ) => ( {
607+ ok : false ,
608+ error :
609+ error instanceof Error
610+ ? error
611+ : new Error ( `Controller readiness failed: ${ String ( error ) } ` ) ,
612+ } ) )
613+ : Promise . resolve ( { ok : true } ) ;
603614
604615 // Persist port metadata
605616 await writeRuntimePorts ( plistDir , {
0 commit comments