File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed
packages/svelte/src/internal/client Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ ' svelte ' : patch
3+ ---
4+
5+ fix: ensure unowned derived dependencies are not duplicated when reactions are skipped
Original file line number Diff line number Diff line change @@ -404,15 +404,9 @@ export function update_reaction(reaction) {
404404 skipped_deps = 0 ;
405405 untracked_writes = null ;
406406 active_reaction = ( flags & ( BRANCH_EFFECT | ROOT_EFFECT ) ) === 0 ? reaction : null ;
407- // prettier-ignore
408407 skip_reaction =
409408 ( flags & UNOWNED ) !== 0 &&
410- ( ! is_flushing_effect ||
411- // If we were previously not in a reactive context and we're reading an unowned derived
412- // that was created inside another reaction, then we don't fully know the real owner and thus
413- // we need to skip adding any reactions for this unowned
414- ( ( previous_reaction === null || previous_untracking ) &&
415- /** @type {Derived } */ ( reaction ) . parent !== null ) ) ;
409+ ( ! is_flushing_effect || previous_reaction === null || previous_untracking ) ;
416410
417411 derived_sources = null ;
418412 set_component_context ( reaction . ctx ) ;
@@ -933,7 +927,10 @@ export function get(signal) {
933927 skipped_deps ++ ;
934928 } else if ( new_deps === null ) {
935929 new_deps = [ signal ] ;
936- } else {
930+ } else if ( ! skip_reaction || ! new_deps . includes ( signal ) ) {
931+ // Normally we can push duplicated dependencies to `new_deps`, but if we're inside
932+ // an unowned derived because skip_reaction is true, then we need to ensure that
933+ // we don't have duplicates
937934 new_deps . push ( signal ) ;
938935 }
939936 }
You can’t perform that action at this time.
0 commit comments