Repository: sveltejs/svelte
File: packages/svelte/src/internal/client/runtime.js (JavaScript)

Code before:
				}

				if (dependency.version > reaction.version) {
					return true;
				}

				if (is_unowned) {
					// TODO is there a more logical place to do this work?
					if (!current_skip_reaction && !dependency?.reactions?.includes(reaction)) {
						// If we are working with an unowned signal as part of an effect (due to !current_skip_reaction)
						// and the version hasn't changed, we still need to check that this reaction
						// if linked to the dependency source – otherwise future updates will not be caught.
						(dependency.reactions ??= []).push(reaction);
					}
				}
			}
		}

		set_signal_status(reaction, CLEAN);
	}

	return false;
}

/**
 * @param {Error} error
 * @param {import("#client").Effect} effect
 * @param {import("#client").ComponentContext | null} component_context
 */
function handle_error(error, effect, component_context) {
	// Given we don't yet have error boundaries, we will just always throw.
	if (!DEV || handled_errors.has(error) || component_context === null) {
		throw error;
	}

	const component_stack = [];

	const effect_name = effect.fn?.name;

	if (effect_name) {
		component_stack.push(effect_name);
	}

	/** @type {import("#client").ComponentContext | null} */
	let current_context = component_context;

	while (current_context !== null) {
		var filename = current_context.function?.filename;

		if (filename) {
			const file = filename.split('/').at(-1);

Review comment (suggestion):
So historically, unowned signals are generally always kept as maybe_dirty, that's so we can check their version. If they are unowned and they're not within an effect, nothing will mark them as maybe dirty again, so they basically stay clean forever. I wonder if you've avoided that somehow though? I guess we can always come back to this if not.

Code after:
			var is_unowned = (flags & UNOWNED) !== 0;

			for (var i = 0; i < dependencies.length; i++) {
				var dependency = dependencies[i];

				if (check_dirtiness(/** @type {import('#client').Derived} */ (dependency))) {
					update_derived(/** @type {import('#client').Derived} */ (dependency));
				}

				if (dependency.version > reaction.version) {
					return true;
				}

				if (is_unowned) {
					// TODO is there a more logical place to do this work?
					if (!current_skip_reaction && !dependency?.reactions?.includes(reaction)) {
						// If we are working with an unowned signal as part of an effect (due to !current_skip_reaction)
						// and the version hasn't changed, we still need to check that this reaction
						// if linked to the dependency source – otherwise future updates will not be caught.
						(dependency.reactions ??= []).push(reaction);
					}
				}
			}
		}

		set_signal_status(reaction, CLEAN);
	}

	return false;
}

/**
 * @param {Error} error
 * @param {import("#client").Effect} effect
 * @param {import("#client").ComponentContext | null} component_context
 */
function handle_error(error, effect, component_context) {
	// Given we don't yet have error boundaries, we will just always throw.
	if (!DEV || handled_errors.has(error) || component_context === null) {
		throw error;
	}

	const component_stack = [];

	const effect_name = effect.fn?.name;

	if (effect_name) {
		component_stack.push(effect_name);
	}

	/** @type {import("#client").ComponentContext | null} */