@@ -188,7 +188,8 @@ export function check_dirtiness(reaction) {
188188 dependency = dependencies [ i ] ;
189189
190190 // We always re-add all reactions (even duplicates) if the derived was
191- // previously disconnected
191+ // previously disconnected, however we don't if it was unowned as we
192+ // de-duplicate dependencies in that case
192193 if ( is_disconnected || ! dependency ?. reactions ?. includes ( reaction ) ) {
193194 ( dependency . reactions ??= [ ] ) . push ( reaction ) ;
194195 }
@@ -404,15 +405,9 @@ export function update_reaction(reaction) {
404405 skipped_deps = 0 ;
405406 untracked_writes = null ;
406407 active_reaction = ( flags & ( BRANCH_EFFECT | ROOT_EFFECT ) ) === 0 ? reaction : null ;
407- // prettier-ignore
408408 skip_reaction =
409409 ( 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 ) ) ;
410+ ( ! is_flushing_effect || previous_reaction === null || previous_untracking ) ;
416411
417412 derived_sources = null ;
418413 set_component_context ( reaction . ctx ) ;
@@ -933,7 +928,10 @@ export function get(signal) {
933928 skipped_deps ++ ;
934929 } else if ( new_deps === null ) {
935930 new_deps = [ signal ] ;
936- } else {
931+ } else if ( ! skip_reaction || ! new_deps . includes ( signal ) ) {
932+ // Normally we can push duplicated dependencies to `new_deps`, but if we're inside
933+ // an unowned derived because skip_reaction is true, then we need to ensure that
934+ // we don't have duplicates
937935 new_deps . push ( signal ) ;
938936 }
939937 }
0 commit comments