Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/stores/executionStore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', {
Expand Down
2 changes: 2 additions & 0 deletions src/stores/executionStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading