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

Retrieving started / pending tasks results in UnhandledPromiseRejectionWarning

harrybaines opened this issue · comments

Description

  • What is the current behavior?

I am using this package to connect to an existing Celery service created in Python through Node.js. On the Python side, I set the task_track_started configuration variable to True, as I wish to monitor the states of tasks after being started. This will help me to get a list of the currently running tasks in Celery on the Node.js side. However, running the following code:

console.log(`Running check for check ID ${checkId}...`)  
const checkResult = check.applyAsync([checkId])
const data = await checkResult.get()

results in the following error/warning:

(node:10624) UnhandledPromiseRejectionWarning: Error: STARTED
  • What is the expected behavior?

If I was to run .get() on the result object, even if the task has not finished yet, it would be nice to return a result with the STARTED state so I know which tasks have been started. Likewise for tasks which are PENDING or FAILED, not just the ones that succeeded (SUCCESS).

  • Please tell us about your environment:

    • Version: 10.15.7
    • OS: macOS Catalina
    • Language: ES6
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, gitter, etc)

I've seen ways of solving this issue through the Python side using AsyncResult(task_id) however I need this functionality on the Node.js side. I see the code in this repository only checks if the result object has succeeded, otherwise a rejection is thrown. Could the AsyncResult behaviour be implemented here?

Hi.
Thank you for reporting the bug.

As I see, it came from PR #25 so the versions after 0.4.0 would generate it.

Fixed it and published it as version 0.5.1.
Please check it out and let me know if the bug remains.

Thank you for reporting again. :)