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.

Unable to call asynchronous functions repeatedly

See original GitHub issue

Hi, I’m trying to run some redis commands at some intervals

var j = schedule.scheduleJob(rule, test(function(reply) {
  console.log(reply);
}));

function test(callback) {
  client.get('mykey', function (err, reply) {
    callback(reply);
  });
}

However, it executes successfully once and then subsequently execution resulted in error:

Cannot read property 'execute' of undefined

What am I doing wrong? Please advise.

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
hydrix9commented, Sep 2, 2016

I get this error

Cannot read property 'execute' of undefined

when I try to run

schedule.scheduleJob('*/5 * * * * *', UpdateTiles("5sec"));

as opposed to

schedule.scheduleJob('*/5 * * * * *', Update5Sec);
function Update5Sec() {
UpdateTiles("5sec");
}

which works perfectly. UpdateTiles has a mongodb query in it. That’s probably the way node-schedule is designed but I’m just putting this here because I found it in google. Exporting it as a function within a module didn’t work as suggested above

0reactions
mKontakiscommented, Oct 12, 2016

@hydrix9 Did you manage to fix it?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to call a async method repeatedly until you get success ...
I have to keep calling this async method from another method until I get success. But if it fails repeatedly for 5 times...
Read more >
Retry asynchronous function using the callback pattern ...
In this article, I'm going to show how you can retry an asynchronous function in JavaScript, using the callback pattern, promise chain ...
Read more >
How to escape async/await hell - freeCodeCamp
While working with Asynchronous JavaScript, people often write multiple statements one after the other and slap an await before a function call.
Read more >
Asynchronous JavaScript: Async/Await Tutorial - Toptal
This article introduces you to asynchronous JavaScript and explains why you should start using async/await functions today.
Read more >
How JavaScript works: Event loop and the rise of Async ...
While the Call Stack has functions to execute, the browser can't do anything else — it's being blocked. This means that the browser...
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