From 795ce0e6a28db99b5c490668d10e47e7c6dfc576 Mon Sep 17 00:00:00 2001 From: heheer <1239331448@qq.com> Date: Fri, 18 Oct 2024 16:18:36 +0800 Subject: [PATCH] fix: add workflow error try catch --- packages/service/core/workflow/dispatch/index.ts | 14 +++++++++++--- .../core/chat/components/WholeResponseModal.tsx | 8 ++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/packages/service/core/workflow/dispatch/index.ts b/packages/service/core/workflow/dispatch/index.ts index 39a26ff10c6..3a11cd11f47 100644 --- a/packages/service/core/workflow/dispatch/index.ts +++ b/packages/service/core/workflow/dispatch/index.ts @@ -38,7 +38,7 @@ import { dispatchQueryExtension } from './tools/queryExternsion'; import { dispatchRunPlugin } from './plugin/run'; import { dispatchPluginInput } from './plugin/runInput'; import { dispatchPluginOutput } from './plugin/runOutput'; -import { removeSystemVariable, valueTypeFormat } from './utils'; +import { formatHttpError, removeSystemVariable, valueTypeFormat } from './utils'; import { filterWorkflowEdges, checkNodeRunStatus @@ -532,8 +532,16 @@ export async function dispatchWorkFlow(data: Props): Promise = await (async () => { - if (callbackMap[node.flowNodeType]) { - return callbackMap[node.flowNodeType](dispatchData); + try { + if (callbackMap[node.flowNodeType]) { + return await callbackMap[node.flowNodeType](dispatchData); + } + } catch (error) { + return { + [DispatchNodeResponseKeyEnum.nodeResponse]: { + error: formatHttpError(error) + } + }; } return {}; })(); diff --git a/projects/app/src/components/core/chat/components/WholeResponseModal.tsx b/projects/app/src/components/core/chat/components/WholeResponseModal.tsx index 6757ae20d00..931cb49e4ef 100644 --- a/projects/app/src/components/core/chat/components/WholeResponseModal.tsx +++ b/projects/app/src/components/core/chat/components/WholeResponseModal.tsx @@ -17,6 +17,7 @@ import { ChatBoxContext } from '../ChatContainer/ChatBox/Provider'; import { useRequest2 } from '@fastgpt/web/hooks/useRequest'; import { getFileIcon } from '@fastgpt/global/common/file/icon'; import EmptyTip from '@fastgpt/web/components/common/EmptyTip'; +import { WarningTwoIcon } from '@chakra-ui/icons'; type sideTabItemType = { moduleLogo?: string; @@ -24,6 +25,7 @@ type sideTabItemType = { runningTime?: number; moduleType: string; // nodeId:string; // abandon + error?: Record; id: string; children: sideTabItemType[]; }; @@ -485,9 +487,10 @@ const SideTabItem = ({ borderRadius={'sm'} /> - + {t(sideBarItem.moduleName as any)} - + {sideBarItem.error && } + {t(sideBarItem.runningTime as any) + 's'} @@ -596,6 +599,7 @@ export const ResponseBox = React.memo(function ResponseBox({ moduleName: item.moduleName, runningTime: item.runningTime, moduleType: item.moduleType, + error: item.error, id: item.id ?? item.nodeId, children };