From 71a9c3f6a4f848a4184e96ef4f51f746228eef30 Mon Sep 17 00:00:00 2001 From: Pedro Carreno <34664891+Pkcarreno@users.noreply.github.com> Date: Tue, 7 Jan 2025 16:36:19 -0400 Subject: [PATCH] fix: prevent multiple executions --- src/features/editor/providers/execution-layer.tsx | 5 ++++- src/features/editor/utils/engine/controller.ts | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/features/editor/providers/execution-layer.tsx b/src/features/editor/providers/execution-layer.tsx index 7499d90..18effbd 100644 --- a/src/features/editor/providers/execution-layer.tsx +++ b/src/features/editor/providers/execution-layer.tsx @@ -89,7 +89,7 @@ export const ExecutionLayerProvider: React.FC = ({ children }) => { throw '01'; } if (status === 'running' || status === 'overflow') { - stopJs(); + throw '02'; } resetOverflowTimeout(); if (!persist_logs) clearLogs(); @@ -100,6 +100,9 @@ export const ExecutionLayerProvider: React.FC = ({ children }) => { if (e === '01') { toast.warning('Nothing to execute!'); } + if (e === '02') { + toast.warning('Execution already running!'); + } } finally { resetExecutionLayer(); } diff --git a/src/features/editor/utils/engine/controller.ts b/src/features/editor/utils/engine/controller.ts index de4df16..2f7ae62 100644 --- a/src/features/editor/utils/engine/controller.ts +++ b/src/features/editor/utils/engine/controller.ts @@ -36,6 +36,10 @@ export function stopJs() { // eslint-disable-next-line max-lines-per-function export function runJs(code: string) { + if (workerRef !== undefined) { + throw '02'; + } + const startTime = Date.now(); const debugMode = SettingsDebugMode();