Skip to content

Commit 0d429c6

Browse files
committed
tweak_self_invalidation
1 parent eac54bb commit 0d429c6

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

packages/svelte/src/internal/client/runtime.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,17 +371,28 @@ export function handle_error(error, effect, previous_effect, component_context)
371371
* @param {Effect} effect
372372
* @param {number} [depth]
373373
*/
374-
function schedule_possible_effect_self_invalidation(signal, effect, depth = 0) {
374+
function schedule_possible_effect_self_invalidation(
375+
signal,
376+
effect,
377+
depth = 0,
378+
visited = new Set()
379+
) {
375380
var reactions = signal.reactions;
376381
if (reactions === null) return;
377382

378383
for (var i = 0; i < reactions.length; i++) {
379384
var reaction = reactions[i];
385+
if (visited.has(reaction)) {
386+
continue;
387+
}
388+
visited.add(reaction);
389+
380390
if ((reaction.f & DERIVED) !== 0) {
381391
schedule_possible_effect_self_invalidation(
382392
/** @type {Derived} */ (reaction),
383393
effect,
384-
depth + 1
394+
depth + 1,
395+
visited
385396
);
386397
} else if (effect === reaction) {
387398
if (depth === 0) {

0 commit comments

Comments
 (0)