From d7f83948a1af0ef3bed61f83e87e826902c96f7d Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 3 Aug 2018 09:27:30 +0200 Subject: Correctly handle video import errors --- server/lib/job-queue/handlers/video-import.ts | 3 ++- server/lib/job-queue/job-queue.ts | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'server/lib/job-queue') diff --git a/server/lib/job-queue/handlers/video-import.ts b/server/lib/job-queue/handlers/video-import.ts index 5a7722153..4f2faab7d 100644 --- a/server/lib/job-queue/handlers/video-import.ts +++ b/server/lib/job-queue/handlers/video-import.ts @@ -35,7 +35,7 @@ async function processVideoImport (job: Bull.Job) { // Get information about this video const { videoFileResolution } = await getVideoFileResolution(tempVideoPath) - const fps = await getVideoFileFPS(tempVideoPath + 's') + const fps = await getVideoFileFPS(tempVideoPath) const stats = await statPromise(tempVideoPath) const duration = await getDurationFromVideoFile(tempVideoPath) @@ -115,6 +115,7 @@ async function processVideoImport (job: Bull.Job) { logger.error('Cannot cleanup files after a video import error.', { err: errUnlink }) } + videoImport.error = err.message videoImport.state = VideoImportState.FAILED await videoImport.save() diff --git a/server/lib/job-queue/job-queue.ts b/server/lib/job-queue/job-queue.ts index 2e14867f2..ffd948b5f 100644 --- a/server/lib/job-queue/job-queue.ts +++ b/server/lib/job-queue/job-queue.ts @@ -79,7 +79,10 @@ class JobQueue { const handler = handlers[handlerName] queue.process(JOB_CONCURRENCY[handlerName], handler) - .catch(err => logger.error('Cannot execute job queue %s.', handlerName, { err })) + + queue.on('failed', (job, err) => { + logger.error('Cannot execute job %d in queue %s.', job.id, handlerName, { payload: job.data, err }) + }) queue.on('error', err => { logger.error('Error in job queue %s.', handlerName, { err }) -- cgit v1.2.3