{"record":{"id":"ffc8760c4bf90461","repo":"BigPizzaV3/CodexPlusPlus","slug":"macos-app-did-not-exit-before-debug-relaunch","errorCode":null,"errorMessage":"macOS app did not exit before debug relaunch: {}","messagePattern":"macOS app did not exit before debug relaunch: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/codex-plus-core/src/launcher.rs","lineNumber":3069,"sourceCode":"        return Ok(());\n    };\n    let _ = Command::new(executable)\n        .args(&command[1..])\n        .stdout(Stdio::null())\n        .stderr(Stdio::null())\n        .status()\n        .await\n        .with_context(|| format!(\"failed to request macOS app quit for {}\", app_dir.display()))?;\n    Ok(())\n}\n\nasync fn quit_macos_app_and_wait(app_dir: &Path) -> anyhow::Result<()> {\n    run_macos_cleanup_command(app_dir, MacosCleanupPolicy::QuitIfNotPreviouslyRunning).await?;\n    let deadline = tokio::time::Instant::now()\n        + std::time::Duration::from_millis(MACOS_DEBUG_TAKEOVER_WAIT_MS);\n    while is_macos_app_running(app_dir).await {\n        if tokio::time::Instant::now() >= deadline {\n            anyhow::bail!(\n                \"macOS app did not exit before debug relaunch: {}\",\n                app_dir.display()\n            );\n        }\n        tokio::time::sleep(std::time::Duration::from_millis(\n            MACOS_DEBUG_TAKEOVER_INTERVAL_MS,\n        ))\n        .await;\n    }\n    let _ = crate::diagnostic_log::append_diagnostic_log(\n        \"launcher.macos_existing_app_without_cdp_stopped\",\n        serde_json::json!({\n            \"app_dir\": app_dir\n        }),\n    );\n    Ok(())\n}\n","sourceCodeStart":3051,"sourceCodeEnd":3087,"githubUrl":"https://github.com/BigPizzaV3/CodexPlusPlus/blob/b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6/crates/codex-plus-core/src/launcher.rs#L3051-L3087","documentation":"Before a debug relaunch on macOS, the launcher asks the running app to quit (via a cleanup command) and then polls `is_macos_app_running` until a deadline (MACOS_DEBUG_TAKEOVER_WAIT_MS). If the app process is still alive after the timeout, relaunching would collide with the old instance, so the takeover is aborted with the app directory in the message.","triggerScenarios":"Running the debug relaunch/takeover flow while the previously launched macOS app bundle at `app_dir` refuses to exit or takes longer than MACOS_DEBUG_TAKEOVER_WAIT_MS to terminate.","commonSituations":"App showing a quit-confirmation dialog or being stuck; app hung/crashed without exiting; another user/session running the same bundle; cleanup AppleScript/kill command failing silently; very short takeover wait timeout on a slow machine.","solutions":["Manually quit the running macOS app (Cmd+Q or `pkill` its process) and retry the debug relaunch","Increase MACOS_DEBUG_TAKEOVER_WAIT_MS to give slow shutdowns more time","Investigate why the cleanup command did not terminate the app (check run_macos_cleanup_command output/logs)"],"exampleFix":"// before\nconst MACOS_DEBUG_TAKEOVER_WAIT_MS: u64 = 5_000;\n// after\nconst MACOS_DEBUG_TAKEOVER_WAIT_MS: u64 = 30_000;","handlingStrategy":"retry","validationCode":"// before relaunch, confirm the app is gone\nif is_macos_app_running(app_dir).await {\n    eprintln!(\"app still running; quit it manually before debug relaunch\");\n}","typeGuard":null,"tryCatchPattern":"loop {\n    match quit_macos_app_and_wait(app_dir).await {\n        Ok(()) => break,\n        Err(e) if e.to_string().contains(\"did not exit\") => {\n            attempt_force_quit(app_dir)?;\n            continue; // bounded retries\n        }\n        Err(e) => return Err(e),\n    }\n}","preventionTips":["Quit the running app manually before starting a debug takeover","Increase the takeover wait timeout on slow machines","Check for quit-blocking dialogs or stuck processes before relaunch","Poll is_macos_app_running with a generous deadline in scripts"],"tags":["rust","macos","process-lifecycle","debug-relaunch","timeout"],"backgroundTag":"operation-timeout","analyzedSha":"b1ed92e5e4a2d74095d4b8db5af43cef7acba9c6","analyzedAt":"2026-09-19T23:35:21.129Z","contentChangedAt":"2026-09-19T23:35:21.129Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}