Skip to content

Commit

Permalink
review update
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-radency committed Oct 18, 2024
1 parent c2ce111 commit 90fe852
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions packages/editor-ui/src/composables/useRunWorkflow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,13 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
return testUrl;
}

function isExecutionResolved(execution: IExecutionResponse | undefined) {
return (
execution &&
(execution.finished || ['error', 'canceled', 'crashed', 'success'].includes(execution.status))
);
}

async function runWorkflowResolvePending(options: {
destinationNode?: string;
triggerNode?: string;
Expand Down Expand Up @@ -382,10 +389,7 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
return node.name === lastNodeExecuted;
});

if (
execution.finished ||
['error', 'canceled', 'crashed', 'success'].includes(execution.status)
) {
if (isExecutionResolved(execution)) {
workflowsStore.setWorkflowExecutionData(execution);
if (timeoutId) clearTimeout(timeoutId);
resolve();
Expand Down Expand Up @@ -446,10 +450,7 @@ export function useRunWorkflow(useRunWorkflowOpts: { router: ReturnType<typeof u
// having active execution id causes issue when re-running workflow that has execution data
// so we remove it after execution has been resolved
const execution = await workflowsStore.getExecution((executionId as string) || '');
if (
execution &&
(execution.finished || ['error', 'canceled', 'crashed', 'success'].includes(execution.status))
) {
if (isExecutionResolved(execution)) {
workflowsStore.activeExecutionId = null;
}

Expand Down

0 comments on commit 90fe852

Please sign in to comment.