Skip to content

Commit d355a8f

Browse files
committed
Fix race condition in handleRun by moving flag before async
1 parent e0045a4 commit d355a8f

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/routes/+page.svelte

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -705,19 +705,20 @@
705705
// Prevent concurrent simulation runs (synchronous check for rapid key presses)
706706
if (simRunning || isRunStarting || pyodideLoading) return;
707707
708+
// Set flag before any async operations to prevent race conditions
709+
isRunStarting = true;
710+
708711
// Auto-initialize if not ready
709712
if (!pyodideReady) {
710713
try {
711714
await initPyodide();
712715
} catch (error) {
713716
console.error('Failed to initialize Pyodide:', error);
717+
isRunStarting = false;
714718
return;
715719
}
716720
}
717721
718-
// Set flag synchronously to prevent race conditions during validation
719-
isRunStarting = true;
720-
721722
try {
722723
// Run simulation
723724
const { nodes, connections } = graphStore.toJSON();

0 commit comments

Comments
 (0)