Skip to content

Commit eba3358

Browse files
waleedlatif1claude
andcommitted
improvement(processing): fix type safety in execution error logging
Replace `as any` cast in non-SSE error path with proper `buildTraceSpans()` transformation, matching the SSE error path. Remove redundant `as any` cast in preprocessing.ts where the types already align. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 9b201d8 commit eba3358

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

apps/sim/app/api/workflows/[id]/execute/route.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -702,10 +702,14 @@ export async function POST(req: NextRequest, { params }: { params: Promise<{ id:
702702
// fire-and-forget call. The `completed` guard in LoggingSession prevents
703703
// double-writes, so this is a no-op — but we avoid awaiting it to reduce
704704
// error-response latency.
705+
const { traceSpans, totalDuration } = executionResult
706+
? buildTraceSpans(executionResult)
707+
: { traceSpans: [], totalDuration: 0 }
708+
705709
void loggingSession.safeCompleteWithError({
706-
totalDurationMs: executionResult?.metadata?.duration,
710+
totalDurationMs: totalDuration || executionResult?.metadata?.duration,
707711
error: { message: errorMessage },
708-
traceSpans: executionResult?.logs as any,
712+
traceSpans,
709713
})
710714

711715
return NextResponse.json(

apps/sim/lib/execution/preprocessing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ async function logPreprocessingError(params: {
480480

481481
try {
482482
const session =
483-
loggingSession || new LoggingSession(workflowId, executionId, triggerType as any, requestId)
483+
loggingSession || new LoggingSession(workflowId, executionId, triggerType, requestId)
484484

485485
await session.safeStart({
486486
userId,

0 commit comments

Comments
 (0)