{"record":{"id":"73bf5461a128d840","repo":"iced-rs/iced","slug":"read-application-metadata","errorCode":null,"errorMessage":"Read application metadata","messagePattern":"Read application metadata","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"debug/src/lib.rs","lineNumber":320,"sourceCode":"        if ENABLED.load(atomic::Ordering::Relaxed) {\n            BEACON.log(event);\n        }\n    }\n\n    #[derive(Debug)]\n    pub struct Span {\n        span: span::Stage,\n        start: Instant,\n    }\n\n    impl Span {\n        pub fn finish(self) {\n            log(client::Event::SpanFinished(self.span, self.start.elapsed()));\n        }\n    }\n\n    static BEACON: LazyLock<Client> = LazyLock::new(|| {\n        let metadata = METADATA.read().expect(\"Read application metadata\");\n\n        client::connect(metadata.clone())\n    });\n\n    static METADATA: RwLock<client::Metadata> = RwLock::new(client::Metadata {\n        name: \"\",\n        theme: None,\n        can_time_travel: false,\n    });\n\n    static LAST_UPDATE: AtomicUsize = AtomicUsize::new(0);\n    static ENABLED: AtomicBool = AtomicBool::new(true);\n}\n\n#[cfg(any(not(feature = \"enable\"), target_arch = \"wasm32\"))]\nmod internal {\n    use crate::core::theme::palette;\n    use crate::core::window;","sourceCodeStart":302,"sourceCodeEnd":338,"githubUrl":"https://github.com/iced-rs/iced/blob/2cffa99b395d84fe469b44dccb56bbacd2f1a157/debug/src/lib.rs#L302-L338","documentation":"The `BEACON` client is a LazyLock: the first debug event initializes it by reading METADATA. `.expect(\"Read application metadata\")` panics when the METADATA RwLock is already poisoned. Logging an event from code that itself holds a METADATA guard would self-deadlock instead, because std's RwLock is not reentrant.","triggerScenarios":"The first `log(...)` call (theme change, span finished, task/subscription counts) after METADATA was poisoned by an earlier panic under one of its guards; or re-entrant logging from inside a METADATA read/write critical section.","commonSituations":"Debug-instrumented apps where a first panic was swallowed by catch_unwind and any later event triggers lazy BEACON initialization; helper code that logs while iterating metadata under a lock.","solutions":["Trace back to the panic that poisoned METADATA — this is downstream damage","Call debug::init eagerly at startup so BEACON initializes before concurrency spreads","Recover from poison in the library: `read().unwrap_or_else(PoisonError::into_inner)`","Never emit debug events from inside code holding a METADATA guard (re-entrancy deadlocks std RwLock)"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"// first event may lazily connect the beacon; keep a failure there non-fatal\nlet _ = std::panic::catch_unwind(|| {\n    debug::tasks_spawned(1);\n});","preventionTips":["Call debug::init before the first loggable event so BEACON initializes on the main thread, not lazily","Never emit debug events from code holding a METADATA guard — std RwLock is not reentrant and will deadlock","After any caught panic in a debug build, prefer restarting the process over reusing poisoned globals","Keep beacon (ICED_BEACON_SERVER_ADDRESS) sessions short-lived during development"],"tags":["rust","iced","debug","beacon","lazy-init","rwlock","lock-poisoning","panic"],"backgroundTag":"lock-poisoned","analyzedSha":"2cffa99b395d84fe469b44dccb56bbacd2f1a157","analyzedAt":"2026-08-16T19:41:49.083Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}