(params: {
error: unknown
loggingSession: LoggingSession
executionId: string
requestId: string
})
| 279 | } |
| 280 | |
| 281 | async function finalizeExecutionError(params: { |
| 282 | error: unknown |
| 283 | loggingSession: LoggingSession |
| 284 | executionId: string |
| 285 | requestId: string |
| 286 | }): Promise<boolean> { |
| 287 | const { error, loggingSession, executionId, requestId } = params |
| 288 | const executionResult = hasExecutionResult(error) ? error.executionResult : undefined |
| 289 | const { traceSpans } = executionResult ? buildTraceSpans(executionResult) : { traceSpans: [] } |
| 290 | |
| 291 | try { |
| 292 | await loggingSession.safeCompleteWithError({ |
| 293 | endedAt: new Date().toISOString(), |
| 294 | totalDurationMs: executionResult?.metadata?.duration || 0, |
| 295 | error: { |
| 296 | message: getErrorMessage(error, 'Execution failed'), |
| 297 | stackTrace: error instanceof Error ? error.stack : undefined, |
| 298 | }, |
| 299 | traceSpans, |
| 300 | }) |
| 301 | |
| 302 | return loggingSession.hasCompleted() |
| 303 | } catch (postExecError) { |
| 304 | logger.error(`[${requestId}] Post-execution error logging failed`, { |
| 305 | error: postExecError, |
| 306 | }) |
| 307 | return false |
| 308 | } finally { |
| 309 | await clearExecutionCancellationSafely(executionId, requestId) |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | export async function executeWorkflowCore( |
| 314 | options: ExecuteWorkflowCoreOptions |
no test coverage detected