libnyanpasu/clash-nyanpasu · critical

Local socket too many crashes

Error message

Local socket too many crashes

What it means

The deep-link plugin's listen() tracks local-socket listener crashes in a static AtomicU16; once the count exceeds 5 it deliberately panics to avoid an infinite crash-rebind loop on the deep-link local socket.

Source

Thrown at backend/tauri-plugin-deep-link/src/windows.rs:76

    Ok(())
}

pub fn unregister(schemes: &[&str]) -> Result<()> {
    for scheme in schemes {
        let hkcu = RegKey::predef(HKEY_CURRENT_USER);
        let base = Path::new("Software").join("Classes").join(scheme);

        hkcu.delete_subkey_all(base)?;
    }

    Ok(())
}

static CRASH_COUNT: AtomicU16 = AtomicU16::new(0);

pub fn listen<F: FnMut(String) + Send + 'static>(mut handler: F) -> Result<()> {
    if CRASH_COUNT.load(Ordering::Acquire) > 5 {
        panic!("Local socket too many crashes");
    }

    std::thread::spawn(move || {
        let name = ID
            .get()
            .expect("listen() called before prepare()")
            .as_str()
            .to_ns_name::<GenericNamespaced>()
            .unwrap();
        tokio::runtime::Builder::new_current_thread()
            .enable_all()
            .build()
            .expect("failed to create tokio runtime")
            .block_on(async move {
                let sdsf = "D:(A;;GA;;;WD)".to_wtf_16().unwrap();
                let sd = SecurityDescriptor::deserialize(&sdsf).expect("Failed to deserialize SD");
                let listener = ListenerOptions::new()
                    .name(name)

View on GitHub (pinned to f7dbce2997)

Solutions

  1. Find and close the process holding the deep-link local socket
  2. Restart the application to reset CRASH_COUNT
  3. Fix the recurring listener crash (check handler panics and socket name conflicts) before re-registering
Defensive patterns

Strategy: retry

Validate before calling

if deep_link::CRASH_COUNT.load(Ordering::Acquire) > 5 {
  // abort registration and report degraded state
  return Err(DeepLinkUnavailable);
}

Try / catch

match std::panic::catch_unwind(|| deep_link::listen(handler)) {
  Ok(res) => res,
  Err(_) => { log::error!("deep-link listener disabled after repeated crashes"); Err(DeepLinkUnavailable) }
}

Prevention

When it happens

Trigger: Calling listen() (directly or via register) when CRASH_COUNT > 5, i.e. after more than five prior listener thread crashes in the same process lifetime.

Common situations: Another process holds the deep-link local socket name, repeated bind failures on Windows named pipes, or a handler repeatedly panicking and respawning the listener.

Related errors


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