Skip to content

How to emit 'failed' event on job that returned Promise on .process callback? #469

@VityaSchel

Description

@VityaSchel

oh please tell me how, I tried everything...

Firstly I tried

queue.process(async (job) => {
   throw 'this error should emit failed event'
}

but it gave me

[UnhandledPromiseRejection: This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason "this error should emit failed event".] {
  code: 'ERR_UNHANDLED_REJECTION'
}

then I tried

queue.process((job) => {
    return new Promise(async (resolve, reject) => {
      try {

      } catch(e) {
        reject(e)
      }
    }
}

But it gives me the same results. I really really need to be able to fail event and use async/await syntax. Is there a way to do that? Does job object has some alternative to reject? Or should I use reportProgress with removeJob?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions