Skip to content

Commit df7967f

Browse files
committed
fix: ensure map iteration order is correct
quick follow-up to #16944 Resetting a map entry does not change its position in the map when iterating. We need to make sure that reset makes that batch jump "to the front" for the "reject all stale batches" logic below. Edge case for which I can't come up with a test case but it _is_ a possibility.
1 parent 28765f8 commit df7967f

File tree

1 file changed

+1
-0
lines changed
  • packages/svelte/src/internal/client/reactivity

1 file changed

+1
-0
lines changed

packages/svelte/src/internal/client/reactivity/deriveds.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ export function async_derived(fn, location) {
144144
batch.increment();
145145

146146
deferreds.get(batch)?.reject(STALE_REACTION);
147+
deferreds.delete(batch); // delete to ensure correct order in Map iteration below
147148
deferreds.set(batch, d);
148149
}
149150
}

0 commit comments

Comments
 (0)