Skip to content

Commit

Permalink
fix: ensure job errors are saved in payload (#9644)
Browse files Browse the repository at this point in the history
Previously, job errors were not saved in payload
  • Loading branch information
AlessioGr authored Dec 1, 2024
1 parent 1e8c9d3 commit e6ea68e
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,17 @@ export async function handleTaskFailed({
if (!job.log) {
job.log = []
}
const errorJSON = error
? {
name: error.name,
message: error.message,
stack: error.stack,
}
: runnerOutput.state

job.log.push({
completedAt: new Date().toISOString(),
error: error ?? runnerOutput.state,
error: errorJSON,
executedAt: executedAt.toISOString(),
input,
output,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,17 @@ export const runJob = async ({
workflowConfig,
})

const errorJSON = hasFinalError
? {
name: err.name,
message: err.message,
stack: err.stack,
}
: undefined
// Tasks update the job if they error - but in case there is an unhandled error (e.g. in the workflow itself, not in a task)
// we need to ensure the job is updated to reflect the error
await updateJob({
error: hasFinalError ? err : undefined,
error: errorJSON,
hasError: hasFinalError, // If reached max retries => final error. If hasError is true this job will not be retried
processing: false,
totalTried: (job.totalTried ?? 0) + 1,
Expand Down

0 comments on commit e6ea68e

Please sign in to comment.