From b671b6679e8611054b27111d34f974a5665c1bbc Mon Sep 17 00:00:00 2001 From: paoloricciuti Date: Mon, 17 Nov 2025 23:23:13 +0100 Subject: [PATCH] fix: only set `derived.v` outside a fork --- packages/svelte/src/internal/client/reactivity/deriveds.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/svelte/src/internal/client/reactivity/deriveds.js b/packages/svelte/src/internal/client/reactivity/deriveds.js index e3434bfbcb..6ef2a052ac 100644 --- a/packages/svelte/src/internal/client/reactivity/deriveds.js +++ b/packages/svelte/src/internal/client/reactivity/deriveds.js @@ -358,8 +358,9 @@ export function update_derived(derived) { // if the derived changes in a fork AND in a subsequent fork/normal state update // IF we are in a tracking context the derived value of the derived will be set // in the batch_values map thus updating it for this batch otherwise it will just be updated - // again during the `get` call - if (batch_values === null) { + // again during the `get` call we also prevent setting the value if we are in a fork + // this will lead to over executing of the derived but would lead to correct values + if (batch_values === null && current_batch?.is_fork !== true) { derived.v = value; } derived.wv = increment_write_version();