From 8b427ddf169fb26c3c32b63b1df7bc6bc4a05cb6 Mon Sep 17 00:00:00 2001 From: Amar Sood Date: Fri, 16 Jan 2026 20:05:09 -0500 Subject: [PATCH] signals: Rebuild stale global cache entries automatically (#4809) * signals: Rebuild stale global cache entries automatically * remove log --------- Co-authored-by: Jonathan Kelley --- packages/signals/src/global/mod.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/signals/src/global/mod.rs b/packages/signals/src/global/mod.rs index b6fdb4a87..f901d304c 100644 --- a/packages/signals/src/global/mod.rs +++ b/packages/signals/src/global/mod.rs @@ -182,12 +182,20 @@ 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; } } + + 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, || {