diff --git a/src/stores/executionStore.test.ts b/src/stores/executionStore.test.ts index f448506321a..e2f8c6eabfd 100644 --- a/src/stores/executionStore.test.ts +++ b/src/stores/executionStore.test.ts @@ -936,6 +936,28 @@ describe('useExecutionStore - workflowStatus', () => { } }) + it('clears running when an account precondition error ends the run', () => { + callStoreJob('job-1', workflowA) + fireExecutionStart('job-1') + expect(store.getWorkflowStatus(workflowA)).toBe('running') + + apiEventHandlers.get('execution_error')!( + new CustomEvent('execution_error', { + detail: { + prompt_id: 'job-1', + node_id: '1', + node_type: 'TestNode', + exception_message: + 'Payment Required: Please add credits to your account to use this node.', + exception_type: 'InsufficientFundsError', + traceback: [] + } + }) + ) + + expect(store.getWorkflowStatus(workflowA)).toBeUndefined() + }) + it('drops pending failed when service-level error fires before storeJob', () => { apiEventHandlers.get('execution_error')!( new CustomEvent('execution_error', { diff --git a/src/stores/executionStore.ts b/src/stores/executionStore.ts index 956d045886b..577cd546e12 100644 --- a/src/stores/executionStore.ts +++ b/src/stores/executionStore.ts @@ -686,6 +686,8 @@ export const useExecutionStore = defineStore('execution', () => { }) if (!precondition) return false + const workflow = jobIdToWorkflow.get(detail.prompt_id) + if (workflow) clearWorkflowStatus(workflow) clearInitializationByJobId(detail.prompt_id) resetExecutionState(detail.prompt_id) return true