question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

use Promises for tasks

See original GitHub issue

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:

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

Issue Analytics

  • State:open
  • Created 8 years ago
  • Reactions:12
  • Comments:17 (4 by maintainers)

github_iconTop GitHub Comments

17reactions
olalondecommented, Mar 1, 2016

Why not standard es6 promises? I personally find it slightly annoying when third party modules use their own promise implementation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using promises - JavaScript - MDN Web Docs
A Promise is an object representing the eventual completion or failure of an asynchronous operation. Since most people are consumers of already- ...
Read more >
How to Learn JavaScript Promises and Async/Await in 20 ...
In JavaScript, we can create a new Promise with new Promise() , which takes in a function as an argument: (resolve, reject) =>...
Read more >
JavaScript promises, mastering the asynchronous - CodinGame
JavaScript promises, mastering the asynchronous · The function job must return a promise object (you are in a NodeJS environment, you can use...
Read more >
25. Promises for asynchronous programming - Exploring JS
Promises are an alternative to callbacks for delivering the results of an asynchronous computation. They require more effort from implementors of asynchronous ...
Read more >
Promise - The Modern JavaScript Tutorial
A Promise object serves as a link between the executor (the “producing code” or “singer”) and the consuming functions (the “fans”), which will ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found