Skip to content

Commit 7819cfc

Browse files
committed
fix(executor): emit finalBlockLogs on queued/HITL error and cancel paths
queued-workflow-execution and human-in-the-loop-manager only attached finalBlockLogs to execution:completed. Without it on cancel/error, reconcileFinalBlockLogs is a no-op and the client sweep flips already-completed blocks to canceled. Mirror the route.ts pattern.
1 parent 910a51a commit 7819cfc

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

apps/sim/lib/workflows/executor/human-in-the-loop-manager.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import type {
2323
SerializedSnapshot,
2424
StreamingExecution,
2525
} from '@/executor/types'
26+
import { hasExecutionResult } from '@/executor/utils/errors'
2627
import { filterOutputForLog } from '@/executor/utils/output-filter'
2728
import type { SerializedConnection } from '@/serializer/types'
2829

@@ -1039,6 +1040,7 @@ export class PauseResumeManager {
10391040
data: {
10401041
error: timeoutErrorMessage,
10411042
duration: result.metadata?.duration || 0,
1043+
finalBlockLogs: result.logs,
10421044
},
10431045
} as ExecutionEvent)
10441046
finalMetaStatus = 'error'
@@ -1048,7 +1050,10 @@ export class PauseResumeManager {
10481050
timestamp: new Date().toISOString(),
10491051
executionId: resumeExecutionId,
10501052
workflowId,
1051-
data: { duration: result.metadata?.duration || 0 },
1053+
data: {
1054+
duration: result.metadata?.duration || 0,
1055+
finalBlockLogs: result.logs,
1056+
},
10521057
} as ExecutionEvent)
10531058
finalMetaStatus = 'cancelled'
10541059
} else if (result.status === 'paused') {
@@ -1083,6 +1088,7 @@ export class PauseResumeManager {
10831088
finalMetaStatus = 'complete'
10841089
}
10851090
} catch (execError) {
1091+
const execErrorResult = hasExecutionResult(execError) ? execError.executionResult : undefined
10861092
writeBufferedEvent({
10871093
type: 'execution:error',
10881094
timestamp: new Date().toISOString(),
@@ -1091,6 +1097,7 @@ export class PauseResumeManager {
10911097
data: {
10921098
error: toError(execError).message,
10931099
duration: 0,
1100+
finalBlockLogs: execErrorResult?.logs,
10941101
},
10951102
} as ExecutionEvent)
10961103
finalMetaStatus = 'error'

apps/sim/lib/workflows/executor/queued-workflow-execution.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ export async function executeQueuedWorkflowJob(
169169
data: {
170170
error: timeoutErrorMessage,
171171
duration: result.metadata?.duration || 0,
172+
finalBlockLogs: result.logs,
172173
},
173174
})
174175

@@ -214,6 +215,7 @@ export async function executeQueuedWorkflowJob(
214215
workflowId,
215216
data: {
216217
duration: result.metadata?.duration || 0,
218+
finalBlockLogs: result.logs,
217219
},
218220
})
219221
await setExecutionMeta(executionId, { status: 'cancelled' })
@@ -290,6 +292,8 @@ export async function executeQueuedWorkflowJob(
290292
})
291293
}
292294

295+
const executionResult = hasExecutionResult(error) ? error.executionResult : undefined
296+
293297
if (eventWriter) {
294298
await eventWriter.write({
295299
type: 'execution:error',
@@ -299,13 +303,12 @@ export async function executeQueuedWorkflowJob(
299303
data: {
300304
error: toError(error).message,
301305
duration: 0,
306+
finalBlockLogs: executionResult?.logs,
302307
},
303308
})
304309
await setExecutionMeta(executionId, { status: 'error' })
305310
}
306311

307-
const executionResult = hasExecutionResult(error) ? error.executionResult : undefined
308-
309312
return buildResult(
310313
'failed',
311314
{

0 commit comments

Comments
 (0)