Automattic / Automattic/kue

use Promises for tasks

Open
#787 17 comments 12 reactions 0 assignees View on GitHub
Discussion Feature Optimization
Dominant language
JavaScript
Stars
9.4k
Forks
858
PR merge metrics
No merged PRs in 30d

Description

We're writing majority of code using async/await these days. So our first thought was to use it for kue-tasks too. Something like this:

``` js
queue.process('hello', async (job) => {
let tmpResult = await someLongBoringOperation(job.data.name);
await otherLongOperation(tmpResult, job.data.planet);
});
```

That doesn't work as kue doesn't distinguish promises from regular functions. Workarounds are mentioned in Readme, but they hurt elegance of app code.

Is there a chance that kue will have "native" support for promises?

The only complication I see is optional `workerCtx` param. Otherwise, the code should be trivial

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the README's documented workarounds and the queue.process entry point shown in the issue. Trace how task callbacks and the optional workerCtx parameter are handled, then define completion as native support for async functions without the current application-level workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.