{"record":{"id":"6b1848d0838f8a78","repo":"DioxusLabs/dioxus","slug":"callback-was-called-after-the-runtime-was-dropped","errorCode":null,"errorMessage":"Callback was called after the runtime was dropped","messagePattern":"Callback was called after the runtime was dropped","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/core/src/events.rs","lineNumber":528,"sourceCode":"            Some(ExternalListenerCallback {\n                callback: Box::new(move |event: Args| f(event).spawn()),\n                runtime: Rc::downgrade(&runtime),\n            }),\n            Location::caller(),\n        );\n        Self { callback, origin }\n    }\n\n    /// Call this callback with the appropriate argument type\n    ///\n    /// This borrows the callback using a RefCell. Recursively calling a callback will cause a panic.\n    #[track_caller]\n    pub fn call(&self, arguments: Args) -> Ret {\n        if let Some(callback) = self.callback.write().as_mut() {\n            let runtime = callback\n                .runtime\n                .upgrade()\n                .expect(\"Callback was called after the runtime was dropped\");\n            let _guard = RuntimeGuard::new(runtime.clone());\n            runtime.with_scope_on_stack(self.origin, || (callback.callback)(arguments))\n        } else {\n            panic!(\"Callback was manually dropped\")\n        }\n    }\n\n    /// Create a `impl FnMut + Copy` closure from the Closure type\n    pub fn into_closure(self) -> impl FnMut(Args) -> Ret + Copy + 'static {\n        move |args| self.call(args)\n    }\n\n    /// Forcibly drop the internal handler callback, releasing memory\n    ///\n    /// This will force any future calls to \"call\" to not doing anything\n    pub fn release(&self) {\n        self.callback.set(None);\n    }","sourceCodeStart":510,"sourceCodeEnd":546,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/24f6a829df0dfa203961a98ea4cae21c2ff27e28/packages/core/src/events.rs#L510-L546","documentation":"Runtime panic raised when an external-listener Callback is invoked after the Dioxus runtime it belongs to has been dropped. The weak runtime reference captured at creation could not be upgraded, so the event has no scheduler to spawn onto.","triggerScenarios":"Thrown at packages/core/src/events.rs:528 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Do not invoke callbacks (event handlers, spawned tasks) after the VirtualDOM/runtime has been dropped; cancel or check the runtime is alive before calling, e.g. by keeping the app running or dropping handles on shutdown."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"24f6a829df0dfa203961a98ea4cae21c2ff27e28","analyzedAt":"2026-08-23T07:10:14.078Z","contentChangedAt":"2026-08-23T07:10:14.078Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}