fix(runtime): wait for CoreBridge init before bootstrap auth

This commit is contained in:
vicrodh committed 2026-02-22 17:59:22 -06:00
1 parent 2e51c2e1f2
commit d7213e06a4
1 file changed
+19 -2
+19 -2
View File
@@ -503,7 +503,24 @@ pub async fn runtime_bootstrap(
},
);
// Step 4: Authenticate CoreBridge/V2 - REQUIRED per ADR
// Step 4: Wait for CoreBridge init, then authenticate V2 - REQUIRED per ADR
let cb_start = std::time::Instant::now();
let cb_timeout = std::time::Duration::from_secs(10);
let cb_poll = std::time::Duration::from_millis(50);
loop {
if core_bridge.try_get().await.is_some() {
break;
}
if cb_start.elapsed() > cb_timeout {
log::error!("[Runtime] CoreBridge not available after 10s");
manager.set_bootstrap_in_progress(false).await;
return Err(RuntimeError::V2NotInitialized);
}
tokio::time::sleep(cb_poll).await;
}
log::info!("[Runtime] CoreBridge ready after {:?}", cb_start.elapsed());
if let Some(bridge) = core_bridge.try_get().await {
match bridge.login(&creds.email, &creds.password).await {
Ok(_) => {
@@ -523,7 +540,7 @@ pub async fn runtime_bootstrap(
}
}
} else {
log::error!("[Runtime] CoreBridge not initialized - cannot complete bootstrap");
log::error!("[Runtime] CoreBridge disappeared after ready check");
manager.set_bootstrap_in_progress(false).await;
return Err(RuntimeError::V2NotInitialized);
}