Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(server): gracefully handle unknown jobs #12870

Merged
merged 1 commit into from
Sep 23, 2024
Merged

Conversation

jrasm91
Copy link
Contributor

@jrasm91 jrasm91 commented Sep 23, 2024

Gracefully handle unknown jobs, by verifying there is a valid handler before calling it.

Sometimes there are jobs in redis when Immich is updated. In the case that job names have changed, it leads to errors like:

[Nest] 6  - 09/23/2024, 3:51:46 PM   ERROR [Microservices:JobService] Unable to run job handler (backgroundTask/undefined): TypeError: handler is not a function
[Nest] 6  - 09/23/2024, 3:51:46 PM   ERROR [Microservices:JobService] TypeError: handler is not a function
    at /usr/src/app/dist/services/job.service.js:148:42
    at Worker.workerHandler [as processFn] (/usr/src/app/dist/repositories/job.repository.js:90:46)
    at Worker.callProcessJob (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:113:21)
    at Worker.processJob (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:394:39)
    at /usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:202:70
    at Worker.retryIfFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:581:30)
    at Worker.run (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:202:45)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[Nest] 6  - 09/23/2024, 3:51:46 PM   ERROR [Microservices:JobService] Object:
Error: Missing lock for job 28. failed
    at Scripts.finishedErrors (/usr/src/app/node_modules/bullmq/dist/cjs/classes/scripts.js:266:24)
    at Job.moveToFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/job.js:427:32)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async handleFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:379:21)
    at async Worker.retryIfFailed (/usr/src/app/node_modules/bullmq/dist/cjs/classes/worker.js:581:24)
    ```

@jrasm91 jrasm91 enabled auto-merge (squash) September 23, 2024 17:22
@jrasm91 jrasm91 merged commit e748945 into main Sep 23, 2024
36 checks passed
@jrasm91 jrasm91 deleted the fix/unknown-job-name branch September 23, 2024 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants