Hmbown/CodeWhale · error

user command registry lock poisoned

Error message

user command registry lock poisoned

What it means

The global user-command registry RwLock was poisoned, meaning a thread panicked while holding the lock and its data may be inconsistent. Readers unwrap with this expect, so any later registry access aborts; the underlying cause is the earlier panic, not this call site.

Source

Thrown at crates/tui/src/commands/user_registry.rs:641

        .read()
        .expect("user command registry lock poisoned")
        .registry
        .clone()
}

#[cfg(test)]
pub fn registry_for_workspace(workspace: Option<&Path>) -> UserCommandRegistry {
    with_registry_for_workspace(workspace, Clone::clone)
}

pub fn with_registry_for_workspace<R>(
    workspace: Option<&Path>,
    f: impl FnOnce(&UserCommandRegistry) -> R,
) -> R {
    let workspace = normalize_workspace(workspace);
    let lock = registry_lock();
    let (plugin_sources, plugin_errors) = {
        let guard = lock.read().expect("user command registry lock poisoned");
        if guard.plugin_workspace == workspace {
            (guard.plugin_sources.clone(), guard.plugin_errors.clone())
        } else {
            (Vec::new(), Vec::new())
        }
    };
    let snapshot = command_dirs_snapshot_with_plugins(workspace.as_deref(), &plugin_sources);
    {
        let guard = lock.read().expect("user command registry lock poisoned");
        if !registry_needs_reload(&guard, &workspace, &snapshot) {
            return f(&guard.registry);
        }
    }

    let replacement = UserCommandRegistry::load_with_sources(
        &user_commands::commands_dirs(workspace.as_deref()),
        &user_commands::workflow_dirs(workspace.as_deref()),
        &plugin_sources,

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Find and fix the panic that occurred while the registry lock was held
  2. Switch to lock.read().unwrap_or_else(|e| e.into_inner()) if registry data is safe to reuse after poisoning
  3. Scope lock guards tightly so fallible operations run outside the critical section
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/tui/src/commands/user_registry.rs:641 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/49089db22e266ae3. Report an issue: GitHub.