Skip to content

Commit

Permalink
fix: prevent multiple executions
Browse files Browse the repository at this point in the history
  • Loading branch information
Pkcarreno committed Jan 7, 2025
1 parent c5a9826 commit 71a9c3f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/features/editor/providers/execution-layer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const ExecutionLayerProvider: React.FC<Props> = ({ children }) => {
throw '01';
}
if (status === 'running' || status === 'overflow') {
stopJs();
throw '02';
}
resetOverflowTimeout();
if (!persist_logs) clearLogs();
Expand All @@ -100,6 +100,9 @@ export const ExecutionLayerProvider: React.FC<Props> = ({ children }) => {
if (e === '01') {
toast.warning('Nothing to execute!');
}
if (e === '02') {
toast.warning('Execution already running!');
}
} finally {
resetExecutionLayer();
}
Expand Down
4 changes: 4 additions & 0 deletions src/features/editor/utils/engine/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit 71a9c3f

Please sign in to comment.