From 9e54e9ae20205182cdcc13e26db9056353c79a15 Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Tue, 22 Jul 2025 22:56:16 +0200 Subject: [PATCH] this fixes the last test somehow --- .../svelte/src/internal/client/reactivity/batch.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/packages/svelte/src/internal/client/reactivity/batch.js b/packages/svelte/src/internal/client/reactivity/batch.js index 2c95985500..f230159978 100644 --- a/packages/svelte/src/internal/client/reactivity/batch.js +++ b/packages/svelte/src/internal/client/reactivity/batch.js @@ -472,11 +472,14 @@ export function flushSync(fn) { batch.flush(); } - // this would be reset in `batch.flush_effects()` but since we are early returning here, - // we need to reset it here as well in case the first time there's 0 queued root effects - last_scheduled_effect = null; + // TODO this feels wrong + if (queued_root_effects.length === 0) { + // this would be reset in `batch.flush_effects()` but since we are early returning here, + // we need to reset it here as well in case the first time there's 0 queued root effects + last_scheduled_effect = null; - return /** @type {T} */ (result); + return /** @type {T} */ (result); + } } batch.flush_effects();