BigPizzaV3/CodexPlusPlus · error
微信连接运行锁已损坏
Error message
微信连接运行锁已损坏
What it means
The WeChat (weixin) connect command stores its running runtime handle behind a global Mutex via weixin_runtime(). Calling .lock() returns Err when the mutex is poisoned — a previous thread panicked while holding the lock — and this error maps that poisoning into a user-facing message meaning the run-state lock is unrecoverable through the normal API.
Solutions
- Restart the CodexPlusPlus manager process to clear the poisoned mutex
- Find and fix the panic that poisoned the lock (check logs from the prior WeChat session)
- Replace lock().map_err with lock().unwrap_or_else(|p| p.into_inner()) if the guarded state is safe to recover
- Audit stop/cleanup paths in the WeChat runtime to remove panics while the lock is held
Example fix
// before
let mut runtime = weixin_runtime()
.lock()
.map_err(|_| anyhow::anyhow!("微信连接运行锁已损坏"))?;
// after
let mut runtime = match weixin_runtime().lock() {
Ok(guard) => guard,
Err(poisoned) => poisoned.into_inner(), // 状态本身可安全恢复时才这样做
}; Defensive patterns
Strategy: try-catch
Try / catch
let mut runtime = match weixin_runtime().lock() {
Ok(guard) => guard,
Err(poisoned) => {
log::warn!("weixin runtime lock was poisoned; recovering state");
poisoned.into_inner() // 仅当受保护状态可安全恢复时
}
}; Prevention
- Never panic while holding the weixin_runtime mutex — convert panics into Result errors in the WeChat session code
- Use poisoned.into_inner() recovery if the guarded runtime state is always safe to reuse
- Check manager logs from the previous WeChat session for the panic that poisoned the lock
- Wrap runtime stop/cleanup logic in catch_unwind if third-party code runs under the lock
When it happens
Trigger: Calling the weixin connect command after some earlier code path panicked while holding the weixin_runtime() mutex, leaving it poisoned so .lock() returns Err(PoisonError).
Common situations: A panic in a prior WeChat connection task (network unwrap, index panic, forced stop path) poisoned the lock; long-running manager process accumulating a poisoned runtime after one bad session; bug in WeixinRuntime drop/stop logic panicking under the lock.
Related errors
- Remote Control recovery state lock poisoned
- 微信连接已在运行或正在停止
- 不支持的管理工具导航: /
- provider target discovery task failed
- rollout changed before rollback
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/6092e398764980b3.
Report an issue: GitHub.
Appendix: source
Thrown at apps/codex-plus-manager/src-tauri/src/commands.rs:1486
let config = codex_plus_core::connect::WeixinConnectConfig {
base_url: settings.weixin_connect_base_url,
token: settings.weixin_connect_token,
account_id: settings.weixin_connect_account_id,
allow_from: settings.weixin_connect_allow_from,
route_tag: settings.weixin_connect_route_tag,
work_dir: settings.weixin_connect_work_dir,
model: settings.weixin_connect_model,
sandbox: settings.weixin_connect_sandbox,
codex_path: settings.weixin_connect_codex_path,
}
.normalized();
if config.token.is_empty() {
anyhow::bail!("微信连接 token 为空");
}
let stop = Arc::new(AtomicBool::new(false));
let mut runtime = weixin_runtime()
.lock()
.map_err(|_| anyhow::anyhow!("微信连接运行锁已损坏"))?;
if runtime.is_some() {
anyhow::bail!("微信连接已在运行或正在停止");
}
let codex_path = codex_plus_core::connect::WeixinCodexPath::new(&config.codex_path);
*runtime = Some(WeixinRuntime {
stop: Arc::clone(&stop),
codex_path: codex_path.clone(),
});
drop(runtime);
let status = weixin_status();
if let Ok(mut current) = status.lock() {
current.state = "starting".to_string();
current.message = "正在启动微信连接...".to_string();
current.account_id = config.account_id.clone();
current.has_token = true;
}
let task_status = Arc::clone(&status);
let task_stop = Arc::clone(&stop);View on GitHub (pinned to b1ed92e5e4)