zed-industries/zed · error
Unable to create instance mutex.
Error message
Unable to create instance mutex.
What it means
is_first_instance panics when CreateMutexW fails to create the Windows instance mutex — an OS-level error (permissions, handle exhaustion) prevents the single-instance check from even being evaluated.
Source
Thrown at crates/zed/src/zed/windows_only_instance.rs:36
PIPE_TYPE_MESSAGE, PIPE_WAIT,
},
Threading::CreateMutexW,
},
},
core::HSTRING,
};
use crate::{Args, OpenListener, RawOpenRequest};
#[inline]
fn is_first_instance() -> bool {
unsafe {
CreateMutexW(
None,
false,
&HSTRING::from(format!("{}-Instance-Mutex", app_identifier())),
)
.expect("Unable to create instance mutex.")
};
unsafe { GetLastError() != ERROR_ALREADY_EXISTS }
}
pub fn handle_single_instance(opener: OpenListener, args: &Args) -> bool {
let is_first_instance = is_first_instance();
if is_first_instance {
// We are the first instance, listen for messages sent from other instances
std::thread::Builder::new()
.name("EnsureSingleton".to_owned())
.spawn(move || {
with_pipe(&|url| {
opener.open(RawOpenRequest {
urls: vec![url],
..Default::default()
})
})
})View on GitHub (pinned to f4178619ac)
Solutions
- Check the Windows error code via GetLastError and log it
- Treat mutex creation failure as 'first instance' with a warning instead of crashing
- Verify app_identifier() produces a valid mutex name
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at crates/zed/src/zed/windows_only_instance.rs:36 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/bbdd683b5c6219f9.
Report an issue: GitHub.