pull/15673/head
ComputerGuy 1 month ago
parent 256c7966aa
commit 99df1db0c2

@ -270,13 +270,46 @@ export function invalidate(source) {
} }
if ( if (
active_reaction !== null && active_reaction !== null &&
!untracking && // since we are untracking the function inside `$inspect.with` we need to add this check
// to ensure we error if state is set inside an inspect effect
(!untracking || (active_reaction.f & INSPECT_EFFECT) !== 0) &&
is_runes() && is_runes() &&
(active_reaction.f & (DERIVED | BLOCK_EFFECT)) !== 0 && (active_reaction.f & (DERIVED | BLOCK_EFFECT | ASYNC | INSPECT_EFFECT)) !== 0 &&
!reaction_sources?.includes(source) !current_sources?.includes(source)
) { ) {
e.state_unsafe_mutation(); e.state_unsafe_mutation();
} }
if (DEV) {
if (tracing_mode_flag || active_effect !== null) {
const error = get_stack('UpdatedAt');
if (error !== null) {
source.updated ??= new Map();
let entry = source.updated.get(error.stack);
if (!entry) {
entry = { error, count: 0 };
source.updated.set(error.stack, entry);
}
entry.count++;
}
}
if (active_effect !== null) {
source.set_during_effect = true;
}
}
if ((source.f & DERIVED) !== 0) {
// if we are assigning to a dirty derived we set it to clean/maybe dirty but we also eagerly execute it to track the dependencies
if ((source.f & DIRTY) !== 0) {
execute_derived(/** @type {Derived} */ (source));
}
set_signal_status(source, (source.f & UNOWNED) === 0 ? CLEAN : MAYBE_DIRTY);
}
source.wv = increment_write_version(); source.wv = increment_write_version();
mark_reactions(source, DIRTY); mark_reactions(source, DIRTY);
@ -298,21 +331,8 @@ export function invalidate(source) {
} }
} }
if (DEV && inspect_effects.size > 0) { if (DEV && inspect_effects.size > 0 && !inspect_effects_deferred) {
const inspects = Array.from(inspect_effects); flush_inspect_effects();
for (const effect of inspects) {
// Mark clean inspect-effects as maybe dirty and then check their dirtiness
// instead of just updating the effects - this way we avoid overfiring.
if ((effect.f & CLEAN) !== 0) {
set_signal_status(effect, MAYBE_DIRTY);
}
if (check_dirtiness(effect)) {
update_effect(effect);
}
}
inspect_effects.clear();
} }
} }

Loading…
Cancel
Save