Skip to content

Add safeguards for invalid job methods in the process function #3531

@manast

Description

@manast

Is your feature request related to a problem? Please describe.
Currently, it is possible to call invalid job methods inside the process function of a worker, for example:

const worker = new Worker(
      queueName,
      async job => {
        await job.moveToDelayed();
      }, { ... }

This call will be performed successfully but later when the job actually completes we will end with strange errors like
Error: Missing lock for job [jobId]... moveToDelayed

Describe the solution you'd like
We should implement safeguards so that the invalid job methods directly throw an exception that will early in development notify the user that the method is invalid and thus it cannot be used inside the process function.

Additional context
For most methods we have special errors that can be thrown from the process function to achieve similar results in a correct way, for example: https://docs.bullmq.io/patterns/process-step-jobs#delaying

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions