{"record":{"id":"25353d6cb23cc205","repo":"zed-industries/zed","slug":"rmshutdown-failed","errorCode":null,"errorMessage":"RmShutdown failed: {:?}","messagePattern":"RmShutdown failed: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/auto_update_helper/src/updater.rs","lineNumber":359,"sourceCode":"    let mut reboot_reasons: u32 = 0;\n    let _ = unsafe { RmGetList(session, &mut needed, &mut count, None, &mut reboot_reasons) };\n\n    if needed == 0 {\n        log::info!(\"No processes are holding handles to the files\");\n        return Ok(());\n    }\n\n    log::info!(\n        \"{} process(es) are holding handles to the files, requesting release...\",\n        needed\n    );\n\n    // Request processes to release their handles\n    // RmShutdown with flags=0 asks applications to release handles gracefully\n    // For Explorer, this typically releases icon cache handles without closing Explorer\n    let err = unsafe { RmShutdown(session, 0, None) };\n    if err.is_err() {\n        anyhow::bail!(\"RmShutdown failed: {:?}\", err);\n    }\n\n    log::info!(\"Successfully requested handle release\");\n    Ok(())\n}\n\n#[allow(clippy::disallowed_methods, reason = \"doesn't run in the main binary\")]\nfn zed_launch_command(app_dir: &Path, launch_arguments: &[OsString]) -> std::process::Command {\n    let mut command = std::process::Command::new(app_dir.join(\"Zed.exe\"));\n    command.args(launch_arguments);\n    command\n}\n\npub(crate) fn perform_update(\n    app_dir: &Path,\n    hwnd: Option<isize>,\n    launch: bool,\n    launch_arguments: &[OsString],","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/auto_update_helper/src/updater.rs#L341-L377","documentation":"`RmShutdown` asks the processes registered with the Restart Manager to gracefully release handles to Zed's files (typically Explorer's icon cache handles). If the API call itself returns an error HRESULT, the updater bails and the update stops. Note the failure is of the API call, not of apps refusing to shut down — refusal is reported through `RmGetList`, not here.","triggerScenarios":"`RmShutdown(session, 0, None)` returns a failing HRESULT: session invalidated (e.g., an earlier error), RPC failure to the service, or the service terminating the session because a registered process exited unexpectedly.","commonSituations":"Explorer or other registered processes crash/restart mid-shutdown; RPC instability; security software terminating RM sessions; repeated update attempts reusing a dead session.","solutions":["Retry the update — transient handle states on Explorer commonly clear on the next attempt or after reboot.","Close other applications before updating to reduce the set of processes in the RM session.","Reboot and let the auto-updater run again from a clean state.","If it repeats, update manually via the full downloaded installer."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"match shutdown_handles(session) {\n    Err(err) if is_transient(&err) => { sleep_backoff(); shutdown_handles(session) }\n    result => result,\n}","preventionTips":["Close applications (especially Explorer-heavy icon-cache churn) before updating to shrink the RM process set.","Retry the update once before investigating — transient RM failures usually clear.","Reboot to reset Restart Manager state when shutdown calls keep failing."],"tags":["windows","restart-manager","hresult","file-locks","auto-update"],"backgroundTag":"windows-api-hresult-failure","analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}