Skip to content

Commit 06ddd80

Browse files
committed
timeout errors
1 parent fe27adf commit 06ddd80

File tree

2 files changed

+83
-24
lines changed

2 files changed

+83
-24
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/terminal/utils.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type React from 'react'
2-
import { RepeatIcon, SplitIcon } from 'lucide-react'
2+
import { AlertTriangleIcon, BanIcon, RepeatIcon, SplitIcon, XCircleIcon } from 'lucide-react'
33
import { getBlock } from '@/blocks'
44
import { TERMINAL_BLOCK_COLUMN_WIDTH } from '@/stores/constants'
55
import type { ConsoleEntry } from '@/stores/terminal'
@@ -12,6 +12,15 @@ const SUBFLOW_COLORS = {
1212
parallel: '#FEE12B',
1313
} as const
1414

15+
/**
16+
* Special block type colors for errors and system messages
17+
*/
18+
const SPECIAL_BLOCK_COLORS = {
19+
error: '#ef4444',
20+
validation: '#f59e0b',
21+
cancelled: '#6b7280',
22+
} as const
23+
1524
/**
1625
* Retrieves the icon component for a given block type
1726
*/
@@ -32,6 +41,18 @@ export function getBlockIcon(
3241
return SplitIcon
3342
}
3443

44+
if (blockType === 'error') {
45+
return XCircleIcon
46+
}
47+
48+
if (blockType === 'validation') {
49+
return AlertTriangleIcon
50+
}
51+
52+
if (blockType === 'cancelled') {
53+
return BanIcon
54+
}
55+
3556
return null
3657
}
3758

@@ -50,6 +71,16 @@ export function getBlockColor(blockType: string): string {
5071
if (blockType === 'parallel') {
5172
return SUBFLOW_COLORS.parallel
5273
}
74+
// Special block types for errors and system messages
75+
if (blockType === 'error') {
76+
return SPECIAL_BLOCK_COLORS.error
77+
}
78+
if (blockType === 'validation') {
79+
return SPECIAL_BLOCK_COLORS.validation
80+
}
81+
if (blockType === 'cancelled') {
82+
return SPECIAL_BLOCK_COLORS.cancelled
83+
}
5384
return '#6b7280'
5485
}
5586

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/hooks/use-workflow-execution.ts

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,31 +1161,53 @@ export function useWorkflowExecution() {
11611161
cancelRunningEntries(activeWorkflowId)
11621162
}
11631163

1164-
if (accumulatedBlockLogs.length === 0) {
1165-
// No blocks executed yet - this is a pre-execution error
1166-
// Use 0 for executionOrder so validation errors appear first
1164+
const isPreExecutionError = accumulatedBlockLogs.length === 0
1165+
// Check if any block already has this error - don't duplicate block errors
1166+
const blockAlreadyHasError = accumulatedBlockLogs.some((log) => log.error)
1167+
1168+
// Only add workflow-level error entry for:
1169+
// 1. Pre-execution errors (validation) - no blocks ran
1170+
// 2. Timeout errors - no block has the error
1171+
if (isPreExecutionError || !blockAlreadyHasError) {
11671172
addConsole({
11681173
input: {},
11691174
output: {},
11701175
success: false,
11711176
error: data.error,
11721177
durationMs: data.duration || 0,
11731178
startedAt: new Date(Date.now() - (data.duration || 0)).toISOString(),
1174-
executionOrder: 0,
1179+
executionOrder: isPreExecutionError ? 0 : Number.MAX_SAFE_INTEGER,
11751180
endedAt: new Date().toISOString(),
11761181
workflowId: activeWorkflowId,
1177-
blockId: 'validation',
1182+
blockId: isPreExecutionError ? 'validation' : 'timeout-error',
11781183
executionId,
1179-
blockName: 'Workflow Validation',
1180-
blockType: 'validation',
1184+
blockName: isPreExecutionError ? 'Workflow Validation' : 'Timeout Error',
1185+
blockType: isPreExecutionError ? 'validation' : 'error',
11811186
})
11821187
}
11831188
},
11841189

1185-
onExecutionCancelled: () => {
1190+
onExecutionCancelled: (data) => {
11861191
if (activeWorkflowId) {
11871192
cancelRunningEntries(activeWorkflowId)
11881193
}
1194+
1195+
// Add console entry for cancellation
1196+
addConsole({
1197+
input: {},
1198+
output: {},
1199+
success: false,
1200+
error: 'Execution was cancelled',
1201+
durationMs: data?.duration || 0,
1202+
startedAt: new Date(Date.now() - (data?.duration || 0)).toISOString(),
1203+
executionOrder: Number.MAX_SAFE_INTEGER,
1204+
endedAt: new Date().toISOString(),
1205+
workflowId: activeWorkflowId,
1206+
blockId: 'cancelled',
1207+
executionId,
1208+
blockName: 'Execution Cancelled',
1209+
blockType: 'cancelled',
1210+
})
11891211
},
11901212
},
11911213
})
@@ -1736,21 +1758,27 @@ export function useWorkflowExecution() {
17361758

17371759
cancelRunningEntries(workflowId)
17381760

1739-
addConsole({
1740-
input: {},
1741-
output: {},
1742-
success: false,
1743-
error: data.error,
1744-
durationMs: data.duration || 0,
1745-
startedAt: new Date(Date.now() - (data.duration || 0)).toISOString(),
1746-
executionOrder: Number.MAX_SAFE_INTEGER,
1747-
endedAt: new Date().toISOString(),
1748-
workflowId,
1749-
blockId: 'workflow-error',
1750-
executionId,
1751-
blockName: 'Workflow Error',
1752-
blockType: 'error',
1753-
})
1761+
// Check if any block already has an error - don't duplicate block errors
1762+
const blockAlreadyHasError = accumulatedBlockLogs.some((log) => log.error)
1763+
1764+
// Only add timeout error entry if no block has the error
1765+
if (!blockAlreadyHasError) {
1766+
addConsole({
1767+
input: {},
1768+
output: {},
1769+
success: false,
1770+
error: data.error,
1771+
durationMs: data.duration || 0,
1772+
startedAt: new Date(Date.now() - (data.duration || 0)).toISOString(),
1773+
executionOrder: Number.MAX_SAFE_INTEGER,
1774+
endedAt: new Date().toISOString(),
1775+
workflowId,
1776+
blockId: 'timeout-error',
1777+
executionId,
1778+
blockName: 'Timeout Error',
1779+
blockType: 'error',
1780+
})
1781+
}
17541782
},
17551783

17561784
onExecutionCancelled: () => {

0 commit comments

Comments
 (0)