mirror of https://github.com/Chocobozzz/PeerTube
Add error info in payload on parent failure
parent
52b6d97250
commit
fb50a233f4
|
@ -1,6 +1,6 @@
|
||||||
|
import { HttpStatusCode, Job, JobState, JobType, ResultList, UserRight } from '@peertube/peertube-models'
|
||||||
import { Job as BullJob } from 'bullmq'
|
import { Job as BullJob } from 'bullmq'
|
||||||
import express from 'express'
|
import express from 'express'
|
||||||
import { HttpStatusCode, Job, JobState, JobType, ResultList, UserRight } from '@peertube/peertube-models'
|
|
||||||
import { isArray } from '../../helpers/custom-validators/misc.js'
|
import { isArray } from '../../helpers/custom-validators/misc.js'
|
||||||
import { JobQueue } from '../../lib/job-queue/index.js'
|
import { JobQueue } from '../../lib/job-queue/index.js'
|
||||||
import {
|
import {
|
||||||
|
@ -87,10 +87,6 @@ async function listJobs (req: express.Request, res: express.Response) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function formatJob (job: BullJob, state?: JobState): Promise<Job> {
|
async function formatJob (job: BullJob, state?: JobState): Promise<Job> {
|
||||||
const error = isArray(job.stacktrace) && job.stacktrace.length !== 0
|
|
||||||
? job.stacktrace[0]
|
|
||||||
: null
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: job.id,
|
id: job.id,
|
||||||
state: state || await job.getState(),
|
state: state || await job.getState(),
|
||||||
|
@ -101,9 +97,16 @@ async function formatJob (job: BullJob, state?: JobState): Promise<Job> {
|
||||||
: undefined,
|
: undefined,
|
||||||
progress: job.progress as number,
|
progress: job.progress as number,
|
||||||
priority: job.opts.priority,
|
priority: job.opts.priority,
|
||||||
error,
|
error: getJobError(job),
|
||||||
createdAt: new Date(job.timestamp),
|
createdAt: new Date(job.timestamp),
|
||||||
finishedOn: new Date(job.finishedOn),
|
finishedOn: new Date(job.finishedOn),
|
||||||
processedOn: new Date(job.processedOn)
|
processedOn: new Date(job.processedOn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getJobError (job: BullJob) {
|
||||||
|
if (isArray(job.stacktrace) && job.stacktrace.length !== 0) return job.stacktrace[0]
|
||||||
|
if (job.failedReason) return job.failedReason
|
||||||
|
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue