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

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

Open
VityaSchel opened this issue Feb 6, 2022 · 0 comments
Labels

Comments

@VityaSchel
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants