Skip to content

Commit f0643e0

Browse files
authored
fix(logs): make child workflow span errors the same as root level workflow errors (#1092)
1 parent 77b0c5b commit f0643e0

File tree

2 files changed

+40
-2
lines changed

2 files changed

+40
-2
lines changed

apps/sim/executor/index.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,14 @@ export class Executor {
455455
success: false,
456456
output: finalOutput,
457457
error: 'Workflow execution was cancelled',
458+
metadata: {
459+
duration: Date.now() - startTime.getTime(),
460+
startTime: context.metadata.startTime!,
461+
workflowConnections: this.actualWorkflow.connections.map((conn: any) => ({
462+
source: conn.source,
463+
target: conn.target,
464+
})),
465+
},
458466
logs: context.blockLogs,
459467
}
460468
}
@@ -503,6 +511,14 @@ export class Executor {
503511
success: false,
504512
output: finalOutput,
505513
error: this.extractErrorMessage(error),
514+
metadata: {
515+
duration: Date.now() - startTime.getTime(),
516+
startTime: context.metadata.startTime!,
517+
workflowConnections: this.actualWorkflow.connections.map((conn: any) => ({
518+
source: conn.source,
519+
target: conn.target,
520+
})),
521+
},
506522
logs: context.blockLogs,
507523
}
508524
} finally {
@@ -530,6 +546,14 @@ export class Executor {
530546
success: false,
531547
output: finalOutput,
532548
error: 'Workflow execution was cancelled',
549+
metadata: {
550+
duration: Date.now() - new Date(context.metadata.startTime!).getTime(),
551+
startTime: context.metadata.startTime!,
552+
workflowConnections: this.actualWorkflow.connections.map((conn: any) => ({
553+
source: conn.source,
554+
target: conn.target,
555+
})),
556+
},
533557
logs: context.blockLogs,
534558
}
535559
}
@@ -596,6 +620,14 @@ export class Executor {
596620
success: false,
597621
output: finalOutput,
598622
error: this.extractErrorMessage(error),
623+
metadata: {
624+
duration: Date.now() - new Date(context.metadata.startTime!).getTime(),
625+
startTime: context.metadata.startTime!,
626+
workflowConnections: this.actualWorkflow.connections.map((conn: any) => ({
627+
source: conn.source,
628+
target: conn.target,
629+
})),
630+
},
599631
logs: context.blockLogs,
600632
}
601633
}

apps/sim/lib/logs/execution/trace-spans/trace-spans.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ export function buildTraceSpans(result: ExecutionResult): {
119119
const flatChildSpans: TraceSpan[] = []
120120
childTraceSpans.forEach((childSpan) => {
121121
// Skip the synthetic workflow span wrapper - we only want the actual block executions
122-
if (childSpan.type === 'workflow' && childSpan.name === 'Workflow Execution') {
122+
if (
123+
childSpan.type === 'workflow' &&
124+
(childSpan.name === 'Workflow Execution' || childSpan.name.endsWith(' workflow'))
125+
) {
123126
// Add its children directly, skipping the synthetic wrapper
124127
if (childSpan.children && Array.isArray(childSpan.children)) {
125128
flatChildSpans.push(...childSpan.children)
@@ -401,7 +404,10 @@ function ensureNestedWorkflowsProcessed(span: TraceSpan): TraceSpan {
401404

402405
childTraceSpans.forEach((childSpan) => {
403406
// Skip synthetic workflow wrappers and get the actual blocks
404-
if (childSpan.type === 'workflow' && childSpan.name === 'Workflow Execution') {
407+
if (
408+
childSpan.type === 'workflow' &&
409+
(childSpan.name === 'Workflow Execution' || childSpan.name.endsWith(' workflow'))
410+
) {
405411
if (childSpan.children && Array.isArray(childSpan.children)) {
406412
// Recursively process each child to handle deeper nesting
407413
childSpan.children.forEach((grandchildSpan) => {

0 commit comments

Comments
 (0)