diff --git a/web/app/components/workflow/hooks/use-workflow-run.ts b/web/app/components/workflow/hooks/use-workflow-run.ts index 75c437fac7..abd73ba40a 100644 --- a/web/app/components/workflow/hooks/use-workflow-run.ts +++ b/web/app/components/workflow/hooks/use-workflow-run.ts @@ -126,6 +126,7 @@ export const useWorkflowRun = () => { onWorkflowFinished, onNodeStarted, onNodeFinished, + onError, ...restCallback } = callback || {} workflowStore.setState({ historyWorkflowData: undefined }) @@ -211,6 +212,22 @@ export const useWorkflowRun = () => { if (onWorkflowFinished) onWorkflowFinished(params) }, + onError: (params) => { + const { + workflowRunningData, + setWorkflowRunningData, + } = workflowStore.getState() + + setWorkflowRunningData(produce(workflowRunningData!, (draft) => { + draft.result = { + ...draft.result, + status: WorkflowRunningStatus.Failed, + } + })) + + if (onError) + onError(params) + }, onNodeStarted: (params) => { const { data } = params const { diff --git a/web/app/components/workflow/panel/debug-and-preview/hooks.ts b/web/app/components/workflow/panel/debug-and-preview/hooks.ts index 7273c4a22f..162c313dab 100644 --- a/web/app/components/workflow/panel/debug-and-preview/hooks.ts +++ b/web/app/components/workflow/panel/debug-and-preview/hooks.ts @@ -203,7 +203,7 @@ export const useChat = ( handleRun( params, { - onData: (message: string, isFirstMessage: boolean, { conversationId: newConversationId, messageId, taskId, errorMessage }: any) => { + onData: (message: string, isFirstMessage: boolean, { conversationId: newConversationId, messageId, taskId }: any) => { responseItem.content = responseItem.content + message if (messageId && !hasSetResponseId) {