setInterval Bug?

Posted on
  • If I run the following code the setInterval fires straight away and continuously, it should only fire every hour:

    function test(){
      console.log("Test Function");
    setInterval(test, 60*60*1000);

    If you change it to this so that it only runs every 24 hours it works OK:

    function test(){
      console.log("Test Function");
    setInterval(test, 24*60*60*1000);

    Is this a bug?

  • What version of Espruino are you using? There was a bug in setInterval fixed in v68.

    See also­ues/416
    (I suspect it effects intervals as well)

  • Yes, that'll be the problem... And while your 24 hour delay doesn't run non-stop, it is unlikely to have the right delay.

    I only found out about it on Friday a few hours before I went on a week's holiday, so there wasn't time to fix it. I'll see if I can get something done tomorrow. In the mean time I'm afraid you'll have to use shorter delays (10 minutes?) and a counter...

  • Many thanks for the replies.

    I am using 1v69.

    I can wait until it is fixed, no worries.

  • It's now fixed, and will be in the 1v70 release (which will be out in 2 weeks).

    If you can't wait, you can get the binary from:­mits/67adc8b39dec7c7f6c3ab6b195597abc6e5­e4928

    Just 'copy link' on the non-wiznet .bin file, and paste it into the 'Advanced Flash' box in the Web IDE settings page.

  • Many thanks Gordon.

    Keep up the excellent work.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

setInterval Bug?

Posted by Avatar for user47955 @user47955