fix: ensure $inspect.trace indicated dirty traced deps correctly

fix-inspect-trace
Dominic Gannaway 4 days ago
parent 49013d7bfa
commit cd2fd4a868

@ -524,21 +524,34 @@ export function update_effect(effect) {
destroy_effect_deriveds(effect); destroy_effect_deriveds(effect);
execute_effect_teardown(effect); execute_effect_teardown(effect);
var sources;
var deps = effect.deps;
if (DEV && tracing_mode_flag && deps !== null) {
sources = new Map();
for (let i = 0; i < deps.length; i++) {
var dep = deps[i];
if ((dep.f & DERIVED) === 0) {
sources.set(dep, dep.version);
}
}
}
var teardown = update_reaction(effect); var teardown = update_reaction(effect);
effect.teardown = typeof teardown === 'function' ? teardown : null; effect.teardown = typeof teardown === 'function' ? teardown : null;
effect.version = current_version; effect.version = current_version;
var version = current_version; deps = effect.deps;
var deps = effect.deps;
// In DEV, we need to handle a case where $inspect.trace() might // In DEV, we need to handle a case where $inspect.trace() might
// incorrectly state a source dependency has not changed when it has. // incorrectly state a source dependency has not changed when it has.
// That's beacuse that source was changed by the same effect, causing // That's beacuse that source was changed by the same effect, causing
// the versions to match. We can avoid this by incrementing the version // the versions to match. We can avoid this by incrementing the version
if (DEV && (effect.f & DIRTY) !== 0 && deps !== null) { if (DEV && tracing_mode_flag && (effect.f & DIRTY) !== 0 && deps !== null) {
for (let i = 0; i < deps.length; i++) { for (let i = 0; i < deps.length; i++) {
var dep = deps[i]; dep = deps[i];
if ((dep.f & DERIVED) === 0 && dep.version === version) { if (sources?.has(dep) && sources.get(dep) !== dep.version) {
dep.version = increment_version(); dep.version = increment_version();
} }
} }

Loading…
Cancel
Save