mirror of
https://github.com/simstudioai/sim.git
synced 2026-02-04 11:45:07 -05:00
fix subflow errors
This commit is contained in:
@@ -17,6 +17,7 @@ import { markExecutionCancelled } from '@/lib/execution/cancellation'
|
||||
import { processInputFileFields } from '@/lib/execution/files'
|
||||
import { preprocessExecution } from '@/lib/execution/preprocessing'
|
||||
import { LoggingSession } from '@/lib/logs/execution/logging-session'
|
||||
import { buildTraceSpans } from '@/lib/logs/execution/trace-spans/trace-spans'
|
||||
import {
|
||||
cleanupExecutionBase64Cache,
|
||||
hydrateUserFilesWithBase64,
|
||||
@@ -879,11 +880,14 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ id:
|
||||
logger.error(`[${requestId}] SSE execution failed: ${errorMessage}`, { isTimeout })
|
||||
|
||||
const executionResult = hasExecutionResult(error) ? error.executionResult : undefined
|
||||
const { traceSpans, totalDuration } = executionResult
|
||||
? buildTraceSpans(executionResult)
|
||||
: { traceSpans: [], totalDuration: 0 }
|
||||
|
||||
await loggingSession.safeCompleteWithError({
|
||||
totalDurationMs: executionResult?.metadata?.duration,
|
||||
totalDurationMs: totalDuration || executionResult?.metadata?.duration,
|
||||
error: { message: errorMessage },
|
||||
traceSpans: executionResult?.logs as any,
|
||||
traceSpans,
|
||||
})
|
||||
|
||||
sendEvent({
|
||||
|
||||
@@ -162,6 +162,8 @@ export class ExecutionEngine {
|
||||
}
|
||||
}
|
||||
|
||||
this.finalizeIncompleteLogs()
|
||||
|
||||
const errorMessage = normalizeError(error)
|
||||
logger.error('Execution failed', { error: errorMessage })
|
||||
|
||||
|
||||
@@ -229,6 +229,10 @@ export function addSubflowErrorLog(
|
||||
}
|
||||
ctx.blockLogs.push(blockLog)
|
||||
|
||||
if (contextExtensions?.onBlockStart) {
|
||||
contextExtensions.onBlockStart(blockId, blockName, blockType, execOrder)
|
||||
}
|
||||
|
||||
if (contextExtensions?.onBlockComplete) {
|
||||
contextExtensions.onBlockComplete(blockId, blockName, blockType, {
|
||||
input: inputData,
|
||||
|
||||
@@ -261,10 +261,14 @@ export class ExecutionLogger implements IExecutionLoggerService {
|
||||
models: costSummary.models,
|
||||
}
|
||||
|
||||
const totalDuration =
|
||||
const rawDurationMs =
|
||||
isResume && existingLog?.startedAt
|
||||
? new Date(endedAt).getTime() - new Date(existingLog.startedAt).getTime()
|
||||
: totalDurationMs
|
||||
const totalDuration =
|
||||
typeof rawDurationMs === 'number' && Number.isFinite(rawDurationMs)
|
||||
? Math.max(0, Math.round(rawDurationMs))
|
||||
: 0
|
||||
|
||||
const [updatedLog] = await db
|
||||
.update(workflowExecutionLogs)
|
||||
|
||||
Reference in New Issue
Block a user