Skip to content

Commit 0397fdf

Browse files
committed
Revert "improvement(executor): correctness-by-construction for workflow logs (#4382)"
This reverts commit add55b4.
1 parent 9eb55e2 commit 0397fdf

14 files changed

Lines changed: 458 additions & 384 deletions

File tree

apps/sim/app/api/workflows/[id]/execute/route.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -919,8 +919,7 @@ async function handleExecutePost(
919919
blockType: string,
920920
executionOrder: number,
921921
iterationContext?: IterationContext,
922-
childWorkflowContext?: ChildWorkflowContext,
923-
blockExecutionId?: string
922+
childWorkflowContext?: ChildWorkflowContext
924923
) => {
925924
reqLogger.info('onBlockStart called', { blockId, blockName, blockType })
926925
sendEvent({
@@ -946,7 +945,6 @@ async function handleExecutePost(
946945
childWorkflowBlockId: childWorkflowContext.parentBlockId,
947946
childWorkflowName: childWorkflowContext.workflowName,
948947
}),
949-
...(blockExecutionId && { blockExecutionId }),
950948
},
951949
})
952950
}
@@ -957,8 +955,7 @@ async function handleExecutePost(
957955
blockType: string,
958956
callbackData: any,
959957
iterationContext?: IterationContext,
960-
childWorkflowContext?: ChildWorkflowContext,
961-
blockExecutionId?: string
958+
childWorkflowContext?: ChildWorkflowContext
962959
) => {
963960
const hasError = callbackData.output?.error
964961
const childWorkflowData = childWorkflowContext
@@ -972,11 +969,6 @@ async function handleExecutePost(
972969
? { childWorkflowInstanceId: callbackData.childWorkflowInstanceId }
973970
: {}
974971

975-
const resolvedBlockExecutionId = blockExecutionId ?? callbackData.blockExecutionId
976-
const blockExecData = resolvedBlockExecutionId
977-
? { blockExecutionId: resolvedBlockExecutionId }
978-
: {}
979-
980972
if (hasError) {
981973
reqLogger.info('onBlockComplete (error) called', {
982974
blockId,
@@ -1010,7 +1002,6 @@ async function handleExecutePost(
10101002
}),
10111003
...childWorkflowData,
10121004
...instanceData,
1013-
...blockExecData,
10141005
},
10151006
})
10161007
} else {
@@ -1045,7 +1036,6 @@ async function handleExecutePost(
10451036
}),
10461037
...childWorkflowData,
10471038
...instanceData,
1048-
...blockExecData,
10491039
},
10501040
})
10511041
}
@@ -1175,6 +1165,7 @@ async function handleExecutePost(
11751165
data: {
11761166
error: timeoutErrorMessage,
11771167
duration: result.metadata?.duration || 0,
1168+
finalBlockLogs: result.logs,
11781169
},
11791170
})
11801171
finalMetaStatus = 'error'
@@ -1188,6 +1179,7 @@ async function handleExecutePost(
11881179
workflowId,
11891180
data: {
11901181
duration: result.metadata?.duration || 0,
1182+
finalBlockLogs: result.logs,
11911183
},
11921184
})
11931185
finalMetaStatus = 'cancelled'
@@ -1252,6 +1244,7 @@ async function handleExecutePost(
12521244
data: {
12531245
error: executionResult?.error || errorMessage,
12541246
duration: executionResult?.metadata?.duration || 0,
1247+
finalBlockLogs: executionResult?.logs,
12551248
},
12561249
})
12571250
finalMetaStatus = 'error'

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

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,25 +230,31 @@ export function useWorkflowExecution() {
230230
durationMs?: number
231231
blockLogs: BlockLog[]
232232
isPreExecutionError?: boolean
233+
finalBlockLogs?: BlockLog[]
233234
}) => {
234235
if (!params.workflowId) return
235236
sharedHandleExecutionErrorConsole(
236-
{ addConsole, updateConsole },
237+
{ addConsole, updateConsole, cancelRunningEntries },
237238
{ ...params, workflowId: params.workflowId }
238239
)
239240
},
240-
[addConsole, updateConsole]
241+
[addConsole, cancelRunningEntries, updateConsole]
241242
)
242243

243244
const handleExecutionCancelledConsole = useCallback(
244-
(params: { workflowId?: string; executionId?: string; durationMs?: number }) => {
245+
(params: {
246+
workflowId?: string
247+
executionId?: string
248+
durationMs?: number
249+
finalBlockLogs?: BlockLog[]
250+
}) => {
245251
if (!params.workflowId) return
246252
sharedHandleExecutionCancelledConsole(
247-
{ addConsole, updateConsole },
253+
{ addConsole, updateConsole, cancelRunningEntries },
248254
{ ...params, workflowId: params.workflowId }
249255
)
250256
},
251-
[addConsole, updateConsole]
257+
[addConsole, cancelRunningEntries, updateConsole]
252258
)
253259

254260
const buildBlockEventHandlers = useCallback(
@@ -1030,6 +1036,8 @@ export function useWorkflowExecution() {
10301036
accumulatedBlockLogs,
10311037
accumulatedBlockStates,
10321038
executedBlockIds,
1039+
consoleMode: 'update',
1040+
includeStartConsoleEntry: true,
10331041
onBlockCompleteCallback: onBlockComplete,
10341042
})
10351043

@@ -1232,6 +1240,7 @@ export function useWorkflowExecution() {
12321240
durationMs: data.duration,
12331241
blockLogs: accumulatedBlockLogs,
12341242
isPreExecutionError,
1243+
finalBlockLogs: data.finalBlockLogs,
12351244
})
12361245

12371246
if (activeWorkflowId && !isExecutingFromChat) {
@@ -1258,6 +1267,7 @@ export function useWorkflowExecution() {
12581267
workflowId: activeWorkflowId,
12591268
executionId: executionIdRef.current,
12601269
durationMs: data?.duration,
1270+
finalBlockLogs: data?.finalBlockLogs,
12611271
})
12621272

12631273
if (activeWorkflowId && !isExecutingFromChat) {
@@ -1674,6 +1684,8 @@ export function useWorkflowExecution() {
16741684
accumulatedBlockLogs,
16751685
accumulatedBlockStates,
16761686
executedBlockIds,
1687+
consoleMode: 'update',
1688+
includeStartConsoleEntry: true,
16771689
})
16781690

16791691
await executionStream.executeFromBlock({
@@ -1743,6 +1755,7 @@ export function useWorkflowExecution() {
17431755
error: data.error,
17441756
durationMs: data.duration,
17451757
blockLogs: accumulatedBlockLogs,
1758+
finalBlockLogs: data.finalBlockLogs,
17461759
})
17471760

17481761
setCurrentExecutionId(workflowId, null)
@@ -1755,6 +1768,7 @@ export function useWorkflowExecution() {
17551768
workflowId,
17561769
executionId: executionIdRef.current,
17571770
durationMs: data?.duration,
1771+
finalBlockLogs: data?.finalBlockLogs,
17581772
})
17591773

17601774
setCurrentExecutionId(workflowId, null)
@@ -1901,6 +1915,8 @@ export function useWorkflowExecution() {
19011915
accumulatedBlockLogs,
19021916
accumulatedBlockStates,
19031917
executedBlockIds,
1918+
consoleMode: 'update',
1919+
includeStartConsoleEntry: true,
19041920
})
19051921

19061922
const capturedExecutionId = executionId
@@ -2001,6 +2017,7 @@ export function useWorkflowExecution() {
20012017
executionId: capturedExecutionId,
20022018
error: data.error,
20032019
blockLogs: accumulatedBlockLogs,
2020+
finalBlockLogs: data.finalBlockLogs,
20042021
})
20052022
},
20062023
onExecutionCancelled: (data) => {
@@ -2021,6 +2038,7 @@ export function useWorkflowExecution() {
20212038
workflowId: reconnectWorkflowId,
20222039
executionId: capturedExecutionId,
20232040
durationMs: data?.duration,
2041+
finalBlockLogs: data?.finalBlockLogs,
20242042
})
20252043
},
20262044
},

0 commit comments

Comments
 (0)