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); + } }); });