File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed
packages/signals/src/global Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -182,12 +182,27 @@ where
182182 let context = get_global_context ( ) ;
183183
184184 // Get the entry if it already exists
185+ let mut evicted_stale_entry = false ;
185186 {
186187 let read = context. map . borrow ( ) ;
187188 if let Some ( signal) = read. get ( & key) {
188- return signal. downcast_ref :: < T > ( ) . cloned ( ) . unwrap ( ) ;
189+ if let Some ( signal) = signal. downcast_ref :: < T > ( ) {
190+ return signal. clone ( ) ;
191+ }
192+ evicted_stale_entry = true ;
193+ #[ cfg( debug_assertions) ]
194+ tracing:: warn!(
195+ ?key,
196+ stored_type = ?signal. type_id( ) ,
197+ expected_type = std:: any:: type_name:: <T >( ) ,
198+ expected_type_id = ?std:: any:: TypeId :: of:: <T >( ) ,
199+ "Global signal cache entry type mismatch; rebuilding entry"
200+ ) ;
189201 }
190202 }
203+ if evicted_stale_entry {
204+ context. map . borrow_mut ( ) . remove ( & key) ;
205+ }
191206 // Otherwise, create it
192207 // Constructors are always run in the root scope
193208 let signal = dioxus_core:: Runtime :: current ( ) . in_scope ( ScopeId :: ROOT , || {
You can’t perform that action at this time.
0 commit comments