libnyanpasu/clash-nyanpasu · error

prepare() called more than once with different identifiers.

Error message

prepare() called more than once with different identifiers.

What it means

prepare() on macOS writes the identifier into a OnceCell that accepts only one value. A second prepare() call with a different identifier makes ID.set() fail and this expect() panics. The identifier must be stable for the process lifetime because it derives the IPC socket path.

Source

Thrown at backend/tauri-plugin-deep-link/src/macos.rs:178

                    };

                    let mut cb = HANDLER.get().unwrap().lock().unwrap();
                    cb(buffer);
                }
                Err(err) => {
                    log::error!("Incoming connection failed: {}", err);
                    continue;
                }
            }
        }
    });

    Ok(())
}

pub fn prepare(identifier: &str) {
    ID.set(identifier.to_string())
        .expect("prepare() called more than once with different identifiers.");
}

View on GitHub (pinned to f7dbce2997)

Solutions

  1. Call prepare() once, from a single location, with a single constant identifier
  2. Remove duplicate prepare() calls from plugin/app init paths
  3. Restart the process instead of re-preparing when re-initializing

Example fix

// before
prepare("com.a.b");
prepare("com.x.y"); // panics
// after
prepare("com.a.b"); // exactly once
Defensive patterns

Strategy: validation

Validate before calling

if ID.get().map(|id| id.as_str()) == Some(identifier) { return; }
assert!(ID.get().is_none(), "prepare() already called");

Type guard

fn is_prepared() -> bool { ID.get().is_some() }

Prevention

When it happens

Trigger: Calling prepare() twice with different bundle identifiers, e.g. once in plugin initialization and once in app setup, or re-running setup on hot reload without a process restart.

Common situations: Dev-time re-initialization; test suites sharing a process across cases with different IDs; duplicated prepare() calls after merging plugin wiring code.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of libnyanpasu/clash-nyanpasu@f7dbce2997 (2026-09-08). Data as JSON: /api/errors/234feaf5b1adcc7a. Report an issue: GitHub.