Skip to content

Commit 6dfbea8

Browse files
fix(schedules): log error cause on scheduled-execution failure paths
The scheduled-job failure paths logged the raw error (.message/stack only) — its `.cause` (the real driver error behind a Drizzle "Failed query: ..." wrapper) was never recorded, and the classified-only `describeRetryableInfrastructureError` returns undefined for unrecognized errors. A real failed run (same incident window as the cell failures) failed in `applyScheduleUpdate` with exactly this unrecorded cause. Added `cause: describeError(error)` (always-on, walks the cause chain) to the applyScheduleUpdate catch, the early-failure catch, and the unhandled-error catch — passed as a second arg so the existing message+stack still emit. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 67ceef4 commit 6dfbea8

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

apps/sim/background/schedule-execution.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { and, eq, isNull, type SQL, sql } from 'drizzle-orm'
1616
import { getHighestPrioritySubscription } from '@/lib/billing/core/subscription'
1717
import type { AsyncExecutionCorrelation } from '@/lib/core/async-jobs/types'
1818
import {
19+
describeError,
1920
describeRetryableInfrastructureError,
2021
isRetryableInfrastructureError,
2122
} from '@/lib/core/errors/retryable-infrastructure'
@@ -156,7 +157,7 @@ async function applyScheduleUpdate(
156157

157158
return updatedRows.length > 0
158159
} catch (error) {
159-
logger.error(`[${requestId}] ${context}`, error)
160+
logger.error(`[${requestId}] ${context}`, error, { cause: describeError(error) })
160161
throw error
161162
}
162163
}
@@ -530,7 +531,13 @@ async function runWorkflowExecution({
530531
}
531532
}
532533

533-
logger.error(`[${requestId}] Early failure in scheduled workflow ${payload.workflowId}`, error)
534+
logger.error(
535+
`[${requestId}] Early failure in scheduled workflow ${payload.workflowId}`,
536+
error,
537+
{
538+
cause: describeError(error),
539+
}
540+
)
534541

535542
if (wasExecutionFinalizedByCore(error, executionId)) {
536543
throw error
@@ -950,7 +957,9 @@ export async function executeScheduleJob(payload: ScheduleExecutionPayload) {
950957
return
951958
}
952959

953-
logger.error(`[${requestId}] Error processing schedule ${payload.scheduleId}`, error)
960+
logger.error(`[${requestId}] Error processing schedule ${payload.scheduleId}`, error, {
961+
cause: describeError(error),
962+
})
954963
await releaseClaim(
955964
now,
956965
`Failed to release schedule ${payload.scheduleId} after unhandled error`

0 commit comments

Comments
 (0)