BigPizzaV3/CodexPlusPlus · warning · anyhow::Error
微信连接已在运行或正在停止
Error message
微信连接已在运行或正在停止
What it means
Only one WeChat connect runtime may exist per process. The start command stores a WeixinRuntime handle (with a stop flag) in a global mutex-protected Option; if that Option is already Some — meaning a connection is running or its stop is in progress — starting a new one bails with this error.
Solutions
- Stop the existing WeChat connection first and wait for it to fully shut down, then start again
- Retry after a short delay if a stop was just issued (runtime slot not yet cleared)
- Restart the manager app if a stale runtime entry blocks new connections
Example fix
// before
cmdConnect();
// after
if (connectStatus !== 'stopped') { await cmdStop(); }
await cmdConnect(); Defensive patterns
Strategy: try-catch
Validate before calling
const status = await invoke('weixin_connect_status'); if (status !== 'stopped') await invoke('weixin_connect_stop'); Try / catch
try { await invoke('weixin_connect_start') } catch (e) { if (String(e).includes('已在运行')) await stopThenRetry(); } Prevention
- Track connection state in the UI and disable start while running
- Wait for confirmed shutdown after stop before restarting
- Debounce the connect button
When it happens
Trigger: Calling the WeChat connect start command (commands.rs ~1488) a second time while runtime.is_some() — either an active connection, or a previous one whose stop flag was set but the runtime entry has not been cleared yet.
Common situations: Double-clicking the connect button; clicking start right after stop while the runtime is still shutting down; a previous session crashed without clearing the global runtime slot.
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
- 微信连接运行锁已损坏
- bridge context lock poisoned
- .codex-global-state.json changed while deleting thread
- .codex-global-state.json changed while restoring sidebar…
- Concurrent adapter upgrade
AI-assisted analysis of BigPizzaV3/CodexPlusPlus@b1ed92e5e4 (2026-09-19).
Data as JSON: /api/errors/0b8947a7b72cf95e.
Report an issue: GitHub.
Appendix: source
Thrown at apps/codex-plus-manager/src-tauri/src/commands.rs:1488
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);
tauri::async_runtime::spawn(async move {
if let Err(error) = codex_plus_core::connect::run_weixin_connect_with_codex_path(View on GitHub (pinned to b1ed92e5e4)