From 71a336c41f9c37dc6cda3a359210584f5eeabf24 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Fri, 14 Mar 2025 15:40:14 -0700 Subject: [PATCH] fix: Rendering race condition --- src/lib/components/View.svelte | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/components/View.svelte b/src/lib/components/View.svelte index 35d616a9..f5ff0eda 100644 --- a/src/lib/components/View.svelte +++ b/src/lib/components/View.svelte @@ -138,8 +138,14 @@ onMount(() => { setupPanZoomObserver(); + let pendingStateChange: Promise | undefined; stateStore.subscribe((state) => { - void handleStateChange(state); + // Queue state changes to prevent race condition + if (pendingStateChange) { + pendingStateChange = pendingStateChange.then(() => handleStateChange(state)); + } else { + pendingStateChange = handleStateChange(state); + } }); });