Skip to content

Commit

Permalink
fix: add workflow error try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
newfish-cmyk committed Oct 18, 2024
1 parent 5efa70f commit 795ce0e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
14 changes: 11 additions & 3 deletions packages/service/core/workflow/dispatch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -532,8 +532,16 @@ export async function dispatchWorkFlow(data: Props): Promise<DispatchFlowRespons

// run module
const dispatchRes: Record<string, any> = 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 {};
})();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,15 @@ 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;
moduleName: string;
runningTime?: number;
moduleType: string;
// nodeId:string; // abandon
error?: Record<string, any>;
id: string;
children: sideTabItemType[];
};
Expand Down Expand Up @@ -485,9 +487,10 @@ const SideTabItem = ({
borderRadius={'sm'}
/>
<Box ml={2}>
<Box fontSize={'xs'} fontWeight={'bold'}>
<Flex fontSize={'xs'} fontWeight={'bold'} alignItems={'center'}>
{t(sideBarItem.moduleName as any)}
</Box>
{sideBarItem.error && <WarningTwoIcon color={'red.500'} ml={2} />}
</Flex>
<Box fontSize={'2xs'} color={'myGray.500'}>
{t(sideBarItem.runningTime as any) + 's'}
</Box>
Expand Down Expand Up @@ -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
};
Expand Down

0 comments on commit 795ce0e

Please sign in to comment.