@@ -128,8 +128,8 @@ let current_version = 0;
128128// to prevent memory leaks, we skip adding the reaction.
129129export let skip_reaction = false ;
130130// Handle collecting all signals which are read during a specific time frame
131- export let is_signals_recorded = false ;
132- let captured_signals = new Set ( ) ;
131+ /** @type { Set<Value> | null } */
132+ export let captured_signals = null ;
133133
134134// Handling runtime component context
135135/** @type {ComponentContext | null } */
@@ -732,7 +732,7 @@ export function get(signal) {
732732 return value ;
733733 }
734734
735- if ( is_signals_recorded ) {
735+ if ( captured_signals !== null ) {
736736 captured_signals . add ( signal ) ;
737737 }
738738
@@ -800,21 +800,18 @@ export function safe_get(signal) {
800800 * @param {() => any } fn
801801 */
802802export function invalidate_inner_signals ( fn ) {
803- var previous_is_signals_recorded = is_signals_recorded ;
804803 var previous_captured_signals = captured_signals ;
805- is_signals_recorded = true ;
806804 captured_signals = new Set ( ) ;
807805 var captured = captured_signals ;
808806 var signal ;
809807 try {
810808 untrack ( fn ) ;
811- } finally {
812- is_signals_recorded = previous_is_signals_recorded ;
813- if ( is_signals_recorded ) {
809+ if ( previous_captured_signals !== null ) {
814810 for ( signal of captured_signals ) {
815811 previous_captured_signals . add ( signal ) ;
816812 }
817813 }
814+ } finally {
818815 captured_signals = previous_captured_signals ;
819816 }
820817 for ( signal of captured ) {
0 commit comments