BigPizzaV3/CodexPlusPlus · error
bridge context is not initialized
Error message
bridge context is not initialized
What it means
watchdog_bridge_context clones the Option<BridgeContext> under the mutex and, if it is None, returns this error: the watchdog is being asked to reuse a bridge context that has never been created (initialize_bridge_context has not run or has not stored a value yet).
Solutions
- Ensure start_bridge_watchdog runs only after initialize_bridge_context has successfully stored Some(ctx) (sequence it or await a ready signal).
- Make watchdog_bridge_context lazily initialize the context instead of erroring.
- Have the watchdog treat this as 'nothing to watch' and skip the tick rather than fail hard.
- Check why bridge initialization failed earlier (ports, app dir, data service) and fix the root cause.
Example fix
// before
let ctx = launcher.watchdog_bridge_context().await?;
// after
let Ok(ctx) = launcher.watchdog_bridge_context().await else { tracing::warn!("bridge not initialized; skipping watchdog tick"); return Ok(()); };
Defensive patterns
Strategy: fallback
Validate before calling
if !launcher.bridge_context_initialized() { tracing::warn!("bridge not initialized yet; deferring watchdog"); return Ok(()); } Type guard
function isInitialized(ctx: BridgeContext | null): ctx is BridgeContext { return ctx !== null; } Try / catch
match launcher.watchdog_bridge_context().await {
Ok(ctx) => watch(ctx).await?,
Err(e) if e.to_string().contains("not initialized") => { /* skip tick, retry next interval */ }
Err(e) => return Err(e),
} Prevention
- Initialize the bridge context before starting the watchdog (strict ordering or a ready signal).
- Treat 'not initialized' as a benign skip in watchdog loops.
- Make watchdog ticks idempotent so ordering races are harmless.
When it happens
Trigger: start_bridge_watchdog (or a watchdog test hook) invoking watchdog_bridge_context before the launcher's initialize path stored Some(ctx) into the shared mutex — e.g. watchdog started concurrently before bridge init finished, or bridge init failed earlier.
Common situations: Race between watchdog startup and bridge initialization; bridge initialization failed silently and the watchdog fires later; calling watchdog-driven restart logic in an environment (test/embedded) where no bridge was set up.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- 当前任务的原生接口尚未就绪,请等待任务加载后点击刷新
- Cannot verify launcher process identity
- 当前对话尚未读取完成,请稍后重试
- 当前对话尚未读取完成,请稍后重试
- 当前 Codex 的 HTTP 服务尚未就绪,请稍后重试
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/3ef6f3956cba2832.
Report an issue: GitHub.
Appendix: source
Thrown at apps/codex-plus-launcher/src/main.rs:45
core: Arc::new(DefaultLaunchHooks::default()),
data: Arc::new(LauncherDataService::default()),
runtime: Arc::new(LauncherRuntimeService::new(
9229,
default_user_script_manager(),
)),
bridge_context: Arc::new(Mutex::new(None)),
browser_monitor: Arc::new(Mutex::new(None)),
}
}
}
impl LauncherHooks {
fn watchdog_bridge_context(&self) -> anyhow::Result<BridgeContext> {
self.bridge_context
.lock()
.map_err(|_| anyhow::anyhow!("bridge context lock poisoned"))?
.clone()
.ok_or_else(|| anyhow::anyhow!("bridge context is not initialized"))
}
}
#[tokio::main]
async fn main() -> Result<()> {
let args = std::env::args().skip(1).collect::<Vec<_>>();
let helper_only = args.iter().any(|arg| arg == "--helper-only");
let options = parse_launch_options(args.iter());
if let Err(error) = launcher_main(args, helper_only, options.clone()).await {
let _ = codex_plus_core::diagnostic_log::append_diagnostic_log(
"launcher.failed",
json!({
"message": error.to_string()
}),
);
if !helper_only {
let _ = options.status_store.save_latest(&LaunchStatus {
status: "failed".to_string(),View on GitHub (pinned to b1ed92e5e4)