From 2a07a275631d47dc15af548641e89a68dec7bc1a Mon Sep 17 00:00:00 2001 From: "Amar Sood (tekacs)" Date: Fri, 17 Oct 2025 13:51:31 -0400 Subject: [PATCH 1/2] signals: Rebuild stale global cache entries automatically --- packages/signals/src/global/mod.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/signals/src/global/mod.rs b/packages/signals/src/global/mod.rs index b6fdb4a87b..a7ef3b1af1 100644 --- a/packages/signals/src/global/mod.rs +++ b/packages/signals/src/global/mod.rs @@ -182,12 +182,27 @@ where let context = get_global_context(); // Get the entry if it already exists + let mut evicted_stale_entry = false; { let read = context.map.borrow(); if let Some(signal) = read.get(&key) { - return signal.downcast_ref::().cloned().unwrap(); + if let Some(signal) = signal.downcast_ref::() { + return signal.clone(); + } + evicted_stale_entry = true; + #[cfg(debug_assertions)] + tracing::warn!( + ?key, + stored_type = ?signal.type_id(), + expected_type = std::any::type_name::(), + expected_type_id = ?std::any::TypeId::of::(), + "Global signal cache entry type mismatch; rebuilding entry" + ); } } + if evicted_stale_entry { + context.map.borrow_mut().remove(&key); + } // Otherwise, create it // Constructors are always run in the root scope let signal = dioxus_core::Runtime::current().in_scope(ScopeId::ROOT, || { From e42212b361b79fbed10365cacbd9741aca83f170 Mon Sep 17 00:00:00 2001 From: Jonathan Kelley Date: Fri, 16 Jan 2026 17:01:48 -0800 Subject: [PATCH 2/2] remove log --- packages/signals/src/global/mod.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/signals/src/global/mod.rs b/packages/signals/src/global/mod.rs index a7ef3b1af1..f901d304c5 100644 --- a/packages/signals/src/global/mod.rs +++ b/packages/signals/src/global/mod.rs @@ -190,16 +190,9 @@ where return signal.clone(); } evicted_stale_entry = true; - #[cfg(debug_assertions)] - tracing::warn!( - ?key, - stored_type = ?signal.type_id(), - expected_type = std::any::type_name::(), - expected_type_id = ?std::any::TypeId::of::(), - "Global signal cache entry type mismatch; rebuilding entry" - ); } } + if evicted_stale_entry { context.map.borrow_mut().remove(&key); }