fix: ensure job errors are saved in payload (#9644)

Previously, job errors were not saved in payload
This commit is contained in:
Alessio Gravili
2024-12-01 13:57:14 -07:00
committed by GitHub
parent 1e8c9d3a09
commit e6ea68e848
2 changed files with 17 additions and 2 deletions

View File

@@ -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,

View File

@@ -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,