{"record":{"id":"234feaf5b1adcc7a","repo":"libnyanpasu/clash-nyanpasu","slug":"prepare-called-more-than-once-with-different-ide-234fea","errorCode":null,"errorMessage":"prepare() called more than once with different identifiers.","messagePattern":"prepare\\(\\) called more than once with different identifiers\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/tauri-plugin-deep-link/src/macos.rs","lineNumber":178,"sourceCode":"                    };\n\n                    let mut cb = HANDLER.get().unwrap().lock().unwrap();\n                    cb(buffer);\n                }\n                Err(err) => {\n                    log::error!(\"Incoming connection failed: {}\", err);\n                    continue;\n                }\n            }\n        }\n    });\n\n    Ok(())\n}\n\npub fn prepare(identifier: &str) {\n    ID.set(identifier.to_string())\n        .expect(\"prepare() called more than once with different identifiers.\");\n}\n","sourceCodeStart":160,"sourceCodeEnd":180,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/backend/tauri-plugin-deep-link/src/macos.rs#L160-L180","documentation":"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.","triggerScenarios":"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.","commonSituations":"Dev-time re-initialization; test suites sharing a process across cases with different IDs; duplicated prepare() calls after merging plugin wiring code.","solutions":["Call prepare() once, from a single location, with a single constant identifier","Remove duplicate prepare() calls from plugin/app init paths","Restart the process instead of re-preparing when re-initializing"],"exampleFix":"// before\nprepare(\"com.a.b\");\nprepare(\"com.x.y\"); // panics\n// after\nprepare(\"com.a.b\"); // exactly once","handlingStrategy":"validation","validationCode":"if ID.get().map(|id| id.as_str()) == Some(identifier) { return; }\nassert!(ID.get().is_none(), \"prepare() already called\");","typeGuard":"fn is_prepared() -> bool { ID.get().is_some() }","tryCatchPattern":null,"preventionTips":["Single prepare() call site with a constant identifier","Remove duplicate calls from plugin and app init","Restart the process rather than re-preparing"],"tags":["rust","initialization","panic","deep-link","macos"],"backgroundTag":"internal-invariant-violation","analyzedSha":"f7dbce2997c633e484f54788035e770b3ee99773","analyzedAt":"2026-09-08T01:24:59.197Z","contentChangedAt":"2026-09-08T01:24:59.197Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}