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

primise for tasks with status FAILURE are not rejected

dc-p8 opened this issue · comments

commented

Description

  • What is the current behavior?

I run a task defined in a python backend, using these lines of code :

//src/app.ts
const task = celery_client.createTask('send_mail_confirmation_code');
const resultAsync = task.applyAsync(null, {
	email,
	code
});
const resultPromise = resultAsync.get();
resultPromise.then(data => {
	console.log('celery returned data', data);
	zeebe_complete.success();
}).catch((error) => {
	console.log('celery returned error ?', error);
	zeebe_complete.error();
});

The task is successfully sent, and the task fail, as you can see in this flower screenshot :
image
(notice that the kwargs are not passed in for whatever reason, I don't know if this can be related to this issue)
and redis result backend :

image

and this is the output of my node program :

worker-dev_1    | celery returned data {
worker-dev_1    |   exc_type: 'TemplateDoesNotExist',
worker-dev_1    |   exc_message: [ 'email_code_confirmation.html' ],
worker-dev_1    |   exc_module: 'django.template.exceptions'
worker-dev_1    | }

As you can see, the promise is resolved even if the task is raising an error and it's status is FAILURE

  • What is the expected behavior?

the promise should be rejected and we should be able to catch the error using de .catch method of the promise returned by the .get() method.

  • Please tell us about your environment:

    • Version: 0.5.1
    • OS:
      • the node app is running within a docker container which use node:14-alpine as image
      • celery version on the backend is 4.4.7
    • Language: here is a sample of my package.json
  "scripts": {
    "dev": "npx ts-node-dev --respawn -- src/app.ts",
    ...
  },
  "dependencies": {
    "celery-node": "^0.5.1",
    "zeebe-node": "0.25.0"
  },
  "devDependencies": {
    "typescript": "4.1.2",
    "ts-node-dev": "1.0.0-pre.63"
  }
commented

I was able to put a breakpoint inside the .get() method.
This is what I have :
image

This is why the promise is resolved...

Edit : got it working using .includes, can I make a MR for this little fix ?