Node.js setInterval() stops executing after 25 days

前端 未结 3 1537
情话喂你
情话喂你 2021-01-02 11:40

In my Node.js application, I use setInterval() to run a specific function every 1 hour. The function is executed properly for about 25 days, then the timer stop

3条回答
  •  时光取名叫无心
    2021-01-02 12:21

    After reading the issue in github, I think they will fix it in the next release. If you need to work around before that, you can try recursive timeout instead. Checkout my code:

    function doSomething() {
        console.log('test');
    }
    
    function doSomethingInterval() {
       doSomething();
       setTimeout(doSomethingInterval, 1000);
    }
    
    doSomethingInterval();
    

提交回复
热议问题