actumn / celery.node

Celery task queue client/worker for nodejs

Home Page:https://celery-node.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a way to update the state of a task?

danielmichalichyn opened this issue · comments

In Celery Python we have the method to update the state of a task, like below:

def task(self):
    try:
        raise ValueError('Some error')
    except Exception as ex:
        self.update_state(state=states.FAILURE, meta={'custom': '...'})
        raise Ignore()

Is there any equivalent method in Celery Node?
My goal is to update the state of the task to FAILURE in case an error occurs in my worker.

I've found out that when we throw an Error from the celery.node worker, the state of the Task is saved as 'SUCCESS'. This is because the state of the task is hard coded inside the taskHandler, when we call storeResult.
Maybe we can implement a CATCH in the taskPromise, so when a error is thrown from our worker, we can store the result as 'FAILURE'?
This is something that is suitable for the celery.node project, if yes, i can make a PR for this.

Hi. Thank you for reporting the issue.
You're right. It would be greatly appreciated if you make a PR.

Thank you.

I've submitted a PR in order to solve this, i'm closing this issue.