@@ -1742,6 +1742,11 @@ export class Executor {
17421742 blockLog . durationMs =
17431743 new Date ( blockLog . endedAt ) . getTime ( ) - new Date ( blockLog . startedAt ) . getTime ( )
17441744
1745+ // If this error came from a child workflow execution, persist its trace spans on the log
1746+ if ( block . metadata ?. id === BlockType . WORKFLOW ) {
1747+ this . attachChildWorkflowSpansToLog ( blockLog , error )
1748+ }
1749+
17451750 // Log the error even if we'll continue execution through error path
17461751 context . blockLogs . push ( blockLog )
17471752
@@ -1820,6 +1825,11 @@ export class Executor {
18201825 status : error . status || 500 ,
18211826 }
18221827
1828+ // Preserve child workflow spans on the block state so downstream logging can render them
1829+ if ( block . metadata ?. id === BlockType . WORKFLOW ) {
1830+ this . attachChildWorkflowSpansToOutput ( errorOutput , error )
1831+ }
1832+
18231833 // Set block state with error output
18241834 context . blockStates . set ( blockId , {
18251835 output : errorOutput ,
@@ -1864,6 +1874,39 @@ export class Executor {
18641874 }
18651875 }
18661876
1877+ /**
1878+ * Copies child workflow trace spans from an error object into a block log.
1879+ * Ensures consistent structure and avoids duplication of inline guards.
1880+ */
1881+ private attachChildWorkflowSpansToLog ( blockLog : BlockLog , error : unknown ) : void {
1882+ const spans = (
1883+ error as { childTraceSpans ?: TraceSpan [ ] ; childWorkflowName ?: string } | null | undefined
1884+ ) ?. childTraceSpans
1885+ if ( Array . isArray ( spans ) && spans . length > 0 ) {
1886+ blockLog . output = {
1887+ ...( blockLog . output || { } ) ,
1888+ childTraceSpans : spans ,
1889+ childWorkflowName : ( error as { childWorkflowName ?: string } | null | undefined )
1890+ ?. childWorkflowName ,
1891+ }
1892+ }
1893+ }
1894+
1895+ /**
1896+ * Copies child workflow trace spans from an error object into a normalized output.
1897+ */
1898+ private attachChildWorkflowSpansToOutput ( output : NormalizedBlockOutput , error : unknown ) : void {
1899+ const spans = (
1900+ error as { childTraceSpans ?: TraceSpan [ ] ; childWorkflowName ?: string } | null | undefined
1901+ ) ?. childTraceSpans
1902+ if ( Array . isArray ( spans ) && spans . length > 0 ) {
1903+ output . childTraceSpans = spans
1904+ output . childWorkflowName = (
1905+ error as { childWorkflowName ?: string } | null | undefined
1906+ ) ?. childWorkflowName
1907+ }
1908+ }
1909+
18671910 /**
18681911 * Activates error paths from a block that had an error.
18691912 * Checks for connections from the block's "error" handle and adds them to the active execution path.
0 commit comments