fix: condition branch panic

This commit is contained in:
Fu Diwei
2025-09-25 17:10:19 +08:00
parent 789ea2ae9a
commit 3d36830bd2
5 changed files with 25 additions and 9 deletions
+2 -2
View File
@@ -200,8 +200,8 @@ func (wd *workflowDispatcher) tryExecuteAsync(task *taskInfo) {
// 捕获 panic
defer func() {
if r := recover(); r != nil {
slog.Default().Warn(fmt.Sprintf("workflow dispatcher panic: %v, stack trace: %s", r, string(debug.Stack())), slog.Any("workflowId", task.WorkflowId), slog.Any("runId", task.RunId))
wd.syslog.Error(fmt.Sprintf("workflow dispatcher panic: %v", r), slog.Any("workflowId", task.WorkflowId), slog.Any("runId", task.RunId))
wd.syslog.Error(fmt.Sprintf("workflow dispatcher panic: %v", r), slog.String("workflowId", task.WorkflowId), slog.String("runId", task.RunId))
slog.Default().Error(fmt.Sprintf("workflow dispatcher panic: %v, stack trace: %s", r, string(debug.Stack())), slog.String("workflowId", task.WorkflowId), slog.String("runId", task.RunId))
if workflowRun != nil {
workflowRun.Status = domain.WorkflowRunStatusTypeFailed
+3
View File
@@ -5,6 +5,7 @@ import (
"errors"
"fmt"
"log/slog"
"runtime/debug"
"sync"
"github.com/samber/lo"
@@ -58,6 +59,8 @@ func (we *workflowEngine) Invoke(ctx context.Context, execution WorkflowExecutio
defer func() {
if r := recover(); r != nil {
we.fireOnErrorHooks(ctx, fmt.Errorf("workflow engine panic: %v", r))
we.syslog.Error(fmt.Sprintf("workflow engine panic: %v", r), slog.String("workflowId", execution.WorkflowId), slog.String("runId", execution.RunId))
slog.Default().Error(fmt.Sprintf("workflow engine panic: %v, stack trace: %s", r, string(debug.Stack())), slog.String("workflowId", execution.WorkflowId), slog.String("runId", execution.RunId))
}
}()
+1 -1
View File
@@ -18,7 +18,7 @@ type VariableState struct {
func (s VariableState) ValueString() string {
switch s.ValueType {
case "string":
return s.Value.(string)
return fmt.Sprintf("%s", s.Value)
case "number":
return fmt.Sprintf("%d", s.Value)
case "boolean":
+6 -4
View File
@@ -1,7 +1,7 @@
import { useEffect, useLayoutEffect, useState } from "react";
import { useTranslation } from "react-i18next";
import { RouterProvider } from "react-router-dom";
import { App, ConfigProvider, type ThemeConfig, theme } from "antd";
import { Alert, App, ConfigProvider, type ThemeConfig, theme } from "antd";
import { type Locale } from "antd/es/locale";
import AntdLocaleEnUs from "antd/locale/en_US";
import AntdLocaleZhCN from "antd/locale/zh_CN";
@@ -107,9 +107,11 @@ const RootApp = () => {
},
}}
>
<App>
<RouterProvider router={router} />
</App>
<Alert.ErrorBoundary>
<App>
<RouterProvider router={router} />
</App>
</Alert.ErrorBoundary>
</ConfigProvider>
);
};
@@ -1,7 +1,7 @@
import { useEffect, useMemo, useRef, useState } from "react";
import { useTranslation } from "react-i18next";
import { EditorState, FlowLayoutDefault } from "@flowgram.ai/fixed-layout-editor";
import { IconBrowserShare, IconCheck, IconDots, IconDownload, IconSettings2, IconTransferOut } from "@tabler/icons-react";
import { IconBrowserShare, IconBug, IconCheck, IconDots, IconDownload, IconSettings2, IconTransferOut } from "@tabler/icons-react";
import { useRequest } from "ahooks";
import { Alert, App, Button, Card, Divider, Dropdown, Empty, Skeleton, Table, type TableProps, Tooltip, Typography, theme } from "antd";
import dayjs from "dayjs";
@@ -83,6 +83,14 @@ const WorkflowRunDetail = ({ className, style, ...props }: WorkflowRunDetailProp
}[mergedData.status] ?? ("info" as const)
}
/>
{!!mergedData.error && (
<Alert
className="mt-1"
icon={<IconBug size="1em" color="var(--color-error)" />}
message={<div className="text-xs text-error">{mergedData.error}</div>}
showIcon
/>
)}
<div className="mt-8">
<Typography.Title level={5}>{t("workflow_run.process")}</Typography.Title>
@@ -228,6 +236,9 @@ const WorkflowRunLogs = ({ runId, runStatus }: { runId: string; runStatus: strin
const [showWhitespace, setShowWhitespace] = useState(true);
const renderLogRecord = (record: Log) => {
let timestamp = dayjs(record.timestamp).format("YYYY-MM-DD HH:mm:ss");
timestamp = `[${timestamp}]`;
let message = <>{record.message}</>;
if (record.data != null && Object.keys(record.data).length > 0) {
message = (
@@ -245,7 +256,7 @@ const WorkflowRunLogs = ({ runId, runStatus }: { runId: string; runStatus: strin
return (
<div className="flex space-x-2" style={{ wordBreak: "break-word" }}>
{showTimestamp ? <div className="font-mono whitespace-nowrap text-stone-400">[{dayjs(record.timestamp).format("YYYY-MM-DD HH:mm:ss")}]</div> : <></>}
{showTimestamp && <div className="font-mono whitespace-nowrap text-stone-400">{timestamp}</div>}
<div
className={mergeCls(
"flex-1 font-mono",