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.

async/await support

See original GitHub issue

What about async/await support? It’s 2017 guys! 😃

//every second jobs
scheduler.scheduleJob('* * * * * *', async () => {
   await whatever(); //2017 is here, yay!
});

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11 (3 by maintainers)

github_iconTop GitHub Comments

9reactions
damianobarbaticommented, Mar 29, 2017

Not really, I love good old callbacks

God may have mercy on you 😂 Got it, I’ll try to PR this. Thanks!

2reactions
zoneccccommented, May 5, 2019

When i wrote a test on await sleep

var job = new schedule.Job(async function () {
  console.log(Date.now());
  await (ms => new Promise(resolve, setTimeout(resolve, ms)))(1000);
  console.log(Date.now());
});
job.schedule(new Date(Date.now() + 3000));
clock.tick(4150);

i got this:

3000
1515561822159

but i was expecting the result of

3000
4000

it seems that the await process blocked the fakeTimer. Any idea, or should this be a sinon issue?

When i wrote a test on await sleep

var job = new schedule.Job(async function () {
  console.log(Date.now());
  await (ms => new Promise(resolve, setTimeout(resolve, ms)))(1000);
  console.log(Date.now());
});
job.schedule(new Date(Date.now() + 3000));
clock.tick(4150);

i got this:

3000
1515561822159

but i was expecting the result of

3000
4000

it seems that the await process blocked the fakeTimer. Any idea, or should this be a sinon issue?

I have the same questions as you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

async function - JavaScript - MDN Web Docs - Mozilla
Async functions can contain zero or more await expressions. Await expressions make promise-returning functions behave as though they're ...
Read more >
Async functions | Can I use... Support tables for HTML5, CSS3 ...
Async functions make it possible to treat functions returning Promise objects as if they were synchronous. Usage % of. all users, all tracked,...
Read more >
Async/await - The Modern JavaScript Tutorial
asynchronous code returns a value, but it wraps the value in a Promise, so that the caller can use it to specify the...
Read more >
Async functions: making promises friendly - web.dev
If you use the async keyword before a function definition, you can then use await within the function. When you await a promise, ......
Read more >
JavaScript Async - W3Schools
ECMAScript 2017 introduced the JavaScript keywords async and await . The following table defines the first browser version with full support for both:...
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